You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "bphillips@ku.edu" <bp...@ku.edu> on 2013/07/15 17:29:59 UTC

Creating Your Own Struts 2 Theme No Longer Works?

I'm updating the themes tutorial
(http://struts.apache.org/release/2.3.x/docs/struts-2-themes.html) but
cannot get my example application to work using the latest version of Struts
2.

The example application is at
http://code.google.com/p/struts2-examples/downloads/detail?name=Themes_Struts_2_Mvn_2_2_1.zip
(I'm updating this code and moving it to our Struts sandbox subversion
repository).

Previously, I thought to create a new theme for a tag you just copied the
tag's theme (e.g. checkboxlist.ftl) to a new file with the same name but in
a directory named /template/[your theme name]/  that is under web app.  

However this seems to no longer work as I'm getting an error that FreeMarker
is no looking for all tag theme definitions (e.g. text.flt, select.ftl)
under /template[your theme name]/.

Any help getting this to work would be great - our Struts 2 documentation on
creating your own theme for a tag is lacking.

Bruce




--
View this message in context: http://struts.1045723.n5.nabble.com/Creating-Your-Own-Struts-2-Theme-No-Longer-Works-tp5713191.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/7/19 Lukasz Lenart <lu...@apache.org>:
> Funny thing,
>
> Jasper registered an opposite issue ->
> https://issues.apache.org/jira/browse/WW-4145

Jasper did a great work and his solution is quite brilliant - it will
be possible to extend themes in many ways :-) Anyway I am wondering if
that isn't too big change to introduce with 2.3.16 and if doesn't
break users' themes, ie. jQuery plugin.

WDYT?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Lukasz Lenart <lu...@apache.org>.
Funny thing,

Jasper registered an opposite issue ->
https://issues.apache.org/jira/browse/WW-4145


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2013/7/18 Lukasz Lenart <lu...@apache.org>:
> 2013/7/17 Lukasz Lenart <lu...@apache.org>:
>> Ok, I have replaced ${parameters.theme} with hardcoded value and
>> everything works - I have tested again Themes_Struts2_Mvn as well.
>> If no objections I'm going to commit the changes.
>
> The change was introduced with [1], but I cannot understand what for :\
>
> [1] https://issues.apache.org/jira/browse/WW-1304
> [2] http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/css_xhtml/checkboxlist.ftl?r1=404861&r2=409958&diff_format=h
> [3] http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/template/FreemarkerTemplateEngine.java?r1=404861&r2=409958&pathrev=409958&diff_format=h
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/7/17 Lukasz Lenart <lu...@apache.org>:
> Ok, I have replaced ${parameters.theme} with hardcoded value and
> everything works - I have tested again Themes_Struts2_Mvn as well.
> If no objections I'm going to commit the changes.

The change was introduced with [1], but I cannot understand what for :\

[1] https://issues.apache.org/jira/browse/WW-1304
[2] http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/css_xhtml/checkboxlist.ftl?r1=404861&r2=409958&diff_format=h
[3] http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/components/template/FreemarkerTemplateEngine.java?r1=404861&r2=409958&pathrev=409958&diff_format=h


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Lukasz Lenart <lu...@apache.org>.
Ok, I have replaced ${parameters.theme} with hardcoded value and
everything works - I have tested again Themes_Struts2_Mvn as well.
If no objections I'm going to commit the changes.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/7/17 bphillips@ku.edu <bp...@ku.edu>:
> Lukasz:
>
>   I understand now.  The change is that I have to put the theme attribute on
> the s:form tag with a value of xhtml and then use the theme attribute on the
> s:checkboxlist tag with a value of KUTheme (my custom check box list theme).
> So the edit.jsp code is:
>
> <s:form action="save" method="post" theme="xhtml">
> <s:textfield key="personBean.firstName" />
> <s:textfield key="personBean.lastName" />
> <s:select key="personBean.sport" list="sports" />
> <s:radio key="personBean.gender" list="genders" />
> <s:select key="personBean.residency" list="states" listKey="stateAbbr"
> listValue="stateName" />
> <s:checkbox key="personBean.over21" />
> <s:checkboxlist key="personBean.carModels" list="carModelsAvailable"
> theme="KUTheme" />
> <s:submit key="submit" />
> </s:form>
>
> That is a change from the previous theme behavior (I don't know how long ago
> the change was made).  Previously I just had to put the theme attribute on
> the s:form tag (e.g. theme="KUTheme") and then Struts 2 would look for the
> ftl files in either the template directory in struts2-core or in a folder
> named KUTheme (my theme name) in the template directory in my applications
> webapp folder.

Yeah... I also cannot locate when/where the change was made - maybe it
was related to Freemarker upgrade, hard to guess. That's why I would
like to improve theme support (to meet what docs provide).


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by "bphillips@ku.edu" <bp...@ku.edu>.
Lukasz:

  I understand now.  The change is that I have to put the theme attribute on
the s:form tag with a value of xhtml and then use the theme attribute on the
s:checkboxlist tag with a value of KUTheme (my custom check box list theme). 
So the edit.jsp code is:

<s:form action="save" method="post" theme="xhtml">
<s:textfield key="personBean.firstName" /> 
<s:textfield key="personBean.lastName" /> 
<s:select key="personBean.sport" list="sports" />
<s:radio key="personBean.gender" list="genders" />
<s:select key="personBean.residency" list="states" listKey="stateAbbr"
listValue="stateName" />
<s:checkbox key="personBean.over21" />
<s:checkboxlist key="personBean.carModels" list="carModelsAvailable"
theme="KUTheme" />
<s:submit key="submit" />
</s:form>

That is a change from the previous theme behavior (I don't know how long ago
the change was made).  Previously I just had to put the theme attribute on
the s:form tag (e.g. theme="KUTheme") and then Struts 2 would look for the
ftl files in either the template directory in struts2-core or in a folder
named KUTheme (my theme name) in the template directory in my applications
webapp folder.

Thank you for the help.

Bruce



--
View this message in context: http://struts.1045723.n5.nabble.com/Creating-Your-Own-Struts-2-Theme-No-Longer-Works-tp5713191p5713230.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/7/16 bphillips@ku.edu <bp...@ku.edu>:
> Thank you for looking at this issue.
>
> I removed the theme attribute from the form tag.  But when I add the theme
> attribute to the s:checkboxList tag I now get this error:

It must be there, <s:form/> with xhtml theme, only <s:checkboxlist/>
must use KUtheme theme

> Error reading included file template/KUTheme/controlheader.ftl
> The problematic instruction:
> ----------
> ==> include
> "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" [on line
> 1, column 1 in template/KUTheme/checkboxlist.ftl]
> ----------
>
> So it appears that since the checkboxlist.ftl has include statements to
> other .ftl files the path to the other .ftl files is no longer referencing
> the .ftl files in the struts2 core jar.
>
> Is this related to your other post on themes?  I know that this used to work
> in an earlier version of Struts 2.

Are you sure? I have just tested with 2.2.1 (removed xhtml theme from
<s:form/>) and get exactly the same exception as for 2.3.15
So basically, this works:

<s:form action="save" method="post" theme="xhtml">
<s:textfield key="personBean.firstName" />
<s:textfield key="personBean.lastName" />
<s:select key="personBean.sport" list="sports" />
<s:radio key="personBean.gender" list="genders" />
<s:select key="personBean.residency" list="states" listKey="stateAbbr"
listValue="stateName" />
<s:checkbox key="personBean.over21" />
<s:checkboxlist key="personBean.carModels" list="carModelsAvailable"
theme="KUtheme"/>
<s:submit key="submit" />
</s:form>

And to solve your problem, ${parameters.theme} must be replaced with
hardcoded value.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


RE: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Martin Gainty <mg...@hotmail.com>.
The webapp (Struts) CL is *supposed to reference the resources from the jar loaded by the webapp first* ..can you confirm
templateDir=template
theme=KUThemeI noticed com.opensymphony.xwork2.util.URLUtil TestCase references all resources relatively located off a jar with a trailing bang so as to be able to construct a valid URL e.g.

 public void testIsJarURL() throws Exception {
        assertTrue(URLUtil.isJarURL(new URL("jar:file:/c:/somelibrary.jar!/com/opensymphony")));
        assertTrue(URLUtil.isJarURL(new URL("zip:/c:/somelibrary.jar!/com/opensymphony")));
        assertTrue(URLUtil.isJarURL(new URL("wsjar:/c:/somelibrary.jar!/com/opensymphony")));
        assertTrue(URLUtil.isJarURL(new URL("vfsfile:/c:/somelibrary.jar!/com/opensymphony")));
        assertTrue(URLUtil.isJarURL(new URL("vfszip:/c:/somelibrary.jar/com/opensymphony")));
    }

which container are you using WL, JBoss, TC, WS, Jetty..?

thanks,
Martin 
______________________________________________ 


> Date: Tue, 16 Jul 2013 06:11:21 -0700
> From: bphillips@ku.edu
> To: dev@struts.apache.org
> Subject: Re: Creating Your Own Struts 2 Theme No Longer Works?
> 
> Thank you for looking at this issue.
> 
> I removed the theme attribute from the form tag.  But when I add the theme
> attribute to the s:checkboxList tag I now get this error:
> 
> 
> Error reading included file template/KUTheme/controlheader.ftl
> The problematic instruction:
> ----------
> ==> include
> "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" [on line
> 1, column 1 in template/KUTheme/checkboxlist.ftl]
> ----------
> 
> So it appears that since the checkboxlist.ftl has include statements to
> other .ftl files the path to the other .ftl files is no longer referencing
> the .ftl files in the struts2 core jar.
> 
> Is this related to your other post on themes?  I know that this used to work
> in an earlier version of Struts 2.
> 
> Bruce
> 
> 
> 
> 
> --
> View this message in context: http://struts.1045723.n5.nabble.com/Creating-Your-Own-Struts-2-Theme-No-Longer-Works-tp5713191p5713215.html
> Sent from the Struts - Dev mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
 		 	   		  

Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by "bphillips@ku.edu" <bp...@ku.edu>.
Thank you for looking at this issue.

I removed the theme attribute from the form tag.  But when I add the theme
attribute to the s:checkboxList tag I now get this error:


Error reading included file template/KUTheme/controlheader.ftl
The problematic instruction:
----------
==> include
"/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" [on line
1, column 1 in template/KUTheme/checkboxlist.ftl]
----------

So it appears that since the checkboxlist.ftl has include statements to
other .ftl files the path to the other .ftl files is no longer referencing
the .ftl files in the struts2 core jar.

Is this related to your other post on themes?  I know that this used to work
in an earlier version of Struts 2.

Bruce




--
View this message in context: http://struts.1045723.n5.nabble.com/Creating-Your-Own-Struts-2-Theme-No-Longer-Works-tp5713191p5713215.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

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


Re: Creating Your Own Struts 2 Theme No Longer Works?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/7/15 bphillips@ku.edu <bp...@ku.edu>:
> I'm updating the themes tutorial
> (http://struts.apache.org/release/2.3.x/docs/struts-2-themes.html) but
> cannot get my example application to work using the latest version of Struts
> 2.
>
> The example application is at
> http://code.google.com/p/struts2-examples/downloads/detail?name=Themes_Struts_2_Mvn_2_2_1.zip
> (I'm updating this code and moving it to our Struts sandbox subversion
> repository).
>
> Previously, I thought to create a new theme for a tag you just copied the
> tag's theme (e.g. checkboxlist.ftl) to a new file with the same name but in
> a directory named /template/[your theme name]/  that is under web app.
>
> However this seems to no longer work as I'm getting an error that FreeMarker
> is no looking for all tag theme definitions (e.g. text.flt, select.ftl)
> under /template[your theme name]/.
>
> Any help getting this to work would be great - our Struts 2 documentation on
> creating your own theme for a tag is lacking.

I have checked out the code and the only problem is missing "theme"
attribute on <s:checkboxlist/>, it should like below:

<s:checkboxlist key="personBean.carModels" list="carModelsAvailable"
theme="KUTheme"/>

After that everything works.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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