struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukasz.len...@googlemail.com>
Subject Re: [Q] JavaTemplate Plugin
Date Wed, 17 Feb 2010 16:43:50 GMT
2010/2/17 Hoying, Ken <Ken_Hoying@premierinc.com>:
> 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

Could you register this as a new issue?
https://issues.apache.org/jira/browse/


Pozdrawiam
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


Mime
View raw message