This ended up being a little tougher to accomplish than I had expected.

I tried to override the TemplateEngineManager by specifying the bean in my 
struts.xml file.  However, struts did not like that there was one already 
loaded from the struts-default.xml.

So 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.

        <filter>
                <filter-name>struts2</filter-name>
                <filter-class>
                        
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
                </filter-class>
                
                <!-- Override so that we can replace struts-default.xml with 
struts-sca-default.xml -->
                <init-param>
                <param-name>config </param-name>
                
<param-value>struts-sca-default.xml,struts-plugin.xml,struts.xml</param-value>
        </init-param>
        </filter>

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)
        {
            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


Thanks,
Ken

-----Original Message-----
From: Hoying, Ken [mailto:ken_hoy...@premierinc.com] 
Sent: Monday, February 15, 2010 12:35 PM
To: Struts Users Mailing List
Subject: [Q] JavaTemplate Plugin

I would like to make use of the JavaTemplate Plugin in order to improve my 
applications performance.  However, I do have "ajax" themed tags, as well as, 
some of my own theme tags.  I perfectly realize that the any non "simple" theme 
tags would not be able to take advantage of the performance improvement.  
However, I cannot seem to get my application to work at all.  Does this mean 
that in order to use this plugin, I can only use the "simple" theme and no 
other?

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)
-----------------------------------------
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer.  Thank you.  Premier Inc.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to