struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Hoying (JIRA)" <>
Subject [jira] Created: (WW-3386) JavaTemplateEngine in mixed theme application
Date Wed, 17 Feb 2010 18:06:28 GMT
JavaTemplateEngine in mixed theme application

                 Key: WW-3386
             Project: Struts 2
          Issue Type: Bug
          Components: Other
    Affects Versions:
            Reporter: Ken Hoying

The JavaTemplateEngine Plugin does not work if you have mixed tags in your application.  For
example, if your application utilizes ajax tags as well as simple tags then you will get an
error like this:

Cannot render tag [head] because theme [ajax] was not found. - [unknown location]
        at org.apache.struts2.components.UIBean.mergeTemplate(
        at org.apache.struts2.components.UIBean.end(

I had attempted to fix the issue by overriding the TemplateEngineManager by adding the bean
to my struts.xml file.  However, Struts would not allow me to override this and gave me the

Caused by: Unable to load bean: type:org.apache.struts2.components.template.TemplateEngineManager - bean - vfsfile:/C:/jboss5/server/sca-app/deploy/scaEar.ear/webapp.war/WEB-INF/classes/struts.xml:40:71
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(

Unfortunately, there also does not appear to be a good way to alter the configuration of these
elements.  I was eventually able to do this.  I created a copy of the struts-default.xml and
placed it in my class path with a different name.  In this new default xml I replaced the
configuration for the TemplateEngineManager with one that specified my class.  I then updated
the filter configuration in my web.xml to load my default xml file instead of the struts default

		<!-- Override so that we can replace struts-default.xml with struts-sca-default.xml -->
        	<param-name>config </param-name>

In my custom TemplateEngineManager, I extended the existing TemplateEngineManager and overrode
the getTemplateEngine() as such:

    public TemplateEngine getTemplateEngine(Template template, String templateTypeOverride)
        TemplateEngine engSelected = super.getTemplateEngine(template, templateTypeOverride);
        if(engSelected instanceof JavaTemplateEngine)
                return engSelected;
            } // end if
                // JavaTemplateEngine currently only supports the "simple" theme, so need
to override
                return super.getTemplateEngine(template, DEFAULT_TEMPLATE_TYPE);
            } // end else
        } // end if
            return engSelected;
        } // end else        
    } // end getTemplateEngine

However, it seems like the JavaTemplateEngine Plugin should work and play better with the
ajax theme out of the box.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message