You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nick Scavelli <ni...@gmail.com> on 2008/07/02 20:55:03 UTC

[S2] Issues with extending themes

I am struggling with the whole "extending theme" functionality in
struts2.  Either I'm doing something incredibly stupid or there's an
issue with extending themes in struts2 (2.1.2 to be more clear).  From
what I've gathered from the Struts 2.x documentation is that I should
be able to just simply define my own custom theme, configure the theme
name and template directory, create a theme.properties file with the
parent=css_xhtml and be done.  No need to add anything other than
that.  Am I wrong to assume this ?  In doing so I get some unexpected
errors:

java.io.FileNotFoundException: Template
/templates/ccast2_0/form-close.ftl not found.
	at freemarker.template.Configuration.getTemplate(Configuration.java:489)
	at freemarker.template.Configuration.getTemplate(Configuration.java:452)
	at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:121)
	at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:558)
	at org.apache.struts2.components.UIBean.end(UIBean.java:512)
	at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
	at org.apache.jsp.struts2.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:176)
	at org.apache.jsp.struts2.login_jsp._jspService(login_jsp.java:83)

Why in the world is it looking for the form-close.ftl file if I'm
extending a theme ?  It should be looking for that file in the
css_xhtml theme.  If it's not there it should look in the xhtml theme,
etc, etc.  It seems to work for the themes in the struts2 jar.  Why
doesn't it work for me ????

Here's what I've done:
/WEB-INF/classes/struts.properties:
struts.ui.theme=ccast2_0
struts.ui.templateDir=templates

/templates/ccast2_0/theme.properties
parent=css_xhtml

Please advise because this is so annoying.

- Nick

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


Re: [S2] Issues with extending themes

Posted by Nick Scavelli <ni...@gmail.com>.
Thanks for your reply, you were right.  Once freemarker has control
it's unaware of the parent theme.  Pretty much all controls have
<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl"
/> in their template.  Once I added my own controlheader.ftl it
worked.  My other problem was that I had templates in my application
root instead of /WEB-INF/classes/.  Once I added it there I saw
freemarker errors, telling me it was the theme variable issue.

Thanks,
Nick

On Thu, Jul 3, 2008 at 3:14 AM, Jeromy Evans
<je...@blueskyminds.com.au> wrote:
> Nick Scavelli wrote:
>>
>> Here's what I've done:
>> /WEB-INF/classes/struts.properties:
>> struts.ui.theme=ccast2_0
>> struts.ui.templateDir=templates
>>
>> /templates/ccast2_0/theme.properties
>> parent=css_xhtml
>>
>> Please advise because this is so annoying.
>>
>>
>
> I can't see anything wrong with that.  I do the same thing in 2.1.2 so I'm
> confident it still works as per 2.0.x.
>
> A common problem problem occurs when you implement a template that includes
> a sub-template with ${parameters.theme} in its path. The issue is that
> ${parameters.theme} equals your theme "ccast2_0" but your theme doesn't
> include the referenced template.
> That is,  the S2 template system knows about template hierarchy to find the
> parent template, but freemarker's include tag does not.
>
> This will cause the exception you're seeing but I can't say exactly where
> without see what you've included in your theme.
> The only solution is to bring more templates into your theme from the parent
> and/or remove the ${parameters.theme} references (which may be in the
> parent).
>
> This issue shouldn't normally apply to form-close.ftl, unless (perhaps?) you
> included form.ftl in your theme but not form-close.ftl.
>
> Note: you'll notice many of the parent templates include hardcoded theme
> names in their include statements precisely for this reason.  There is no
> fix without an overhaul of the S2 template system.
>
> Hope that helps,
> Jeromy Evans
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: [S2] Issues with extending themes

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Nick Scavelli wrote:
> Here's what I've done:
> /WEB-INF/classes/struts.properties:
> struts.ui.theme=ccast2_0
> struts.ui.templateDir=templates
>
> /templates/ccast2_0/theme.properties
> parent=css_xhtml
>
> Please advise because this is so annoying.
>
>   

I can't see anything wrong with that.  I do the same thing in 2.1.2 so 
I'm confident it still works as per 2.0.x.

A common problem problem occurs when you implement a template that 
includes a sub-template with ${parameters.theme} in its path. 
The issue is that ${parameters.theme} equals your theme "ccast2_0" but 
your theme doesn't include the referenced template.
That is,  the S2 template system knows about template hierarchy to find 
the parent template, but freemarker's include tag does not.

This will cause the exception you're seeing but I can't say exactly 
where without see what you've included in your theme.
The only solution is to bring more templates into your theme from the 
parent and/or remove the ${parameters.theme} references (which may be in 
the parent).

This issue shouldn't normally apply to form-close.ftl, unless (perhaps?) 
you included form.ftl in your theme but not form-close.ftl.

Note: you'll notice many of the parent templates include hardcoded theme 
names in their include statements precisely for this reason.  There is 
no fix without an overhaul of the S2 template system.

Hope that helps,
Jeromy Evans



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