Return-Path: Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: (qmail 28706 invoked from network); 17 Feb 2010 18:06:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Feb 2010 18:06:51 -0000 Received: (qmail 56044 invoked by uid 500); 17 Feb 2010 18:06:50 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 55970 invoked by uid 500); 17 Feb 2010 18:06:50 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 55718 invoked by uid 99); 17 Feb 2010 18:06:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2010 18:06:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2010 18:06:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B3717234C4AE for ; Wed, 17 Feb 2010 10:06:28 -0800 (PST) Message-ID: <2203133.339231266429988733.JavaMail.jira@brutus.apache.org> Date: Wed, 17 Feb 2010 18:06:28 +0000 (UTC) From: "Ken Hoying (JIRA)" To: issues@struts.apache.org Subject: [jira] Created: (WW-3386) JavaTemplateEngine in mixed theme application MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 JavaTemplateEngine in mixed theme application --------------------------------------------- Key: WW-3386 URL: https://issues.apache.org/jira/browse/WW-3386 Project: Struts 2 Issue Type: Bug Components: Other Affects Versions: 2.1.8.1 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: {code} Cannot render tag [head] because theme [ajax] was not found. - [unknown location] at org.apache.struts2.views.java.JavaTemplateEngine.renderTemplate(JavaTemplateEngine.java:58) at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:559) at org.apache.struts2.components.UIBean.end(UIBean.java:513) {code} 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 exception: {code} Caused by: Unable to load bean: type:org.apache.struts2.components.template.TemplateEngineManager class:com.premierinc.sca.actions.util.ScaTemplateEngineManager - 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(XmlConfigurationProvider.java:221) at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:169) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) {code} 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 xml. {code:xml} struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter config struts-sca-default.xml,struts-plugin.xml,struts.xml {code} In my custom TemplateEngineManager, I extended the existing TemplateEngineManager and overrode the getTemplateEngine() as such: {code:java} public TemplateEngine getTemplateEngine(Template template, String templateTypeOverride) { TemplateEngine engSelected = super.getTemplateEngine(template, templateTypeOverride); if(engSelected instanceof JavaTemplateEngine) { if("simple".equalsIgnoreCase(template.getTheme())) { return engSelected; } // end if else { // JavaTemplateEngine currently only supports the "simple" theme, so need to override return super.getTemplateEngine(template, DEFAULT_TEMPLATE_TYPE); } // end else } // end if else { return engSelected; } // end else } // end getTemplateEngine {code} 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.