You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Eric B <eb...@hotmail.com> on 2013/11/06 17:55:56 UTC
Trying to us JS files as templates/attributes in JSP files but not
processing properly
I don't know if this is not permissible, but I thought I could embed any kind of file as an attribute in a template.
For example, I have the following definitions:
<definition name="REGEXP:([^.]+)" template="/WEB-INF/views/tiles/layouts/ace/default.jsp" preparer="testPreparer">
<put-attribute name="meta" value="/WEB-INF/views/tiles/{options[defaultPaths]}/meta.jsp"/>
<put-attribute name="head" value="/WEB-INF/views/tiles/{options[defaultPaths]}/head.jsp"/>
<put-attribute name="header" value="/WEB-INF/views/tiles/{options[defaultPaths]}/header.jsp"/>
<put-attribute name="menu" value="/WEB-INF/views/tiles/{options[defaultPaths]}/menu.jsp"/>
<put-attribute name="body" value="/WEB-INF/views/tiles/{options[defaultPaths]}/body.jsp"/>
<put-attribute name="onReady" value=".page.onReady//{options[defaultPaths]}" />
<put-list-attribute name="defaultPaths" cascade="true" >
<add-attribute value="{1}"/>
<add-attribute value="default"/>
</put-list-attribute>
</definition>
<definition name="REGEXP:^\.page\.onReady//(.+)" template="/WEB-INF/views/tiles/layouts/ace/onReady.jsp">
<put-attribute name="onReady" value="/WEB-INF/views/tiles/{1}/onReady.js" />
</definition>
I have the following files in my paths:
/WEB-INF/views/tiles/layouts/ace/default.jsp
/WEB-INF/views/tiles/layouts/ace/onReady.jsp
/WEB-INF/vies/tiles/default/head.jsp
/WEB-INF/vies/tiles/default/menu.jsp
/WEB-INF/vies/tiles/secure/login/meta.jsp
/WEB-INF/vies/tiles/secure/login/header.jsp
/WEB-INF/vies/tiles/secure/login/body.jsp
/WEB-INF/vies/tiles/secure/login/onReady.js
When I navigate to template: secure/login I am expecting the following:
WEB-INF/views/tiles/layouts/ace/default.jsp
-> /WEB-INF/vies/tiles/secure/login/meta.jsp
-> /WEB-INF/vies/tiles/default/head.jsp
-> /WEB-INF/vies/tiles/secure/login/header.jsp
-> /WEB-INF/vies/tiles/default/menu.jsp
-> /WEB-INF/vies/tiles/secure/login/body.jsp
-> /WEB-INF/views/tiles/layouts/ace/onReady.jsp
-> /WEB-INF/views/tiles/secure/login/onReady.js
However, the onReady.jsp included as an attribute in the default.jsp file is not properly rendered. If I change the name of onReady.js to
onReady.js.jsp, everthing works properly. If I leave the template attribute as onReady.js, then instead of getting my js files included (as I
expect), I get the entire default.jsp file embdeded as though it was the "onReady" attribute.
I think I have probably done a poor job of explaining this, so if something is unclear, please let me know. Is there no way to include a files
contents as is?
Thanks,
Eric
Re: Trying to us JS files as templates/attributes in JSP files but
not processing properly
Posted by Eric B <eb...@hotmail.com>.
On 13-11-06 4:58 PM, Mick Semb Wever wrote:
> For testing sake, does it work ok if you collapse these definitions
> together into just…
>
> <definition name="REGEXP:([^.]+)" template="/WEB-INF/views/tiles/layouts/ace/default.jsp" preparer="testPreparer">
> <put-attribute name="meta" value="/WEB-INF/views/tiles/{options[defaultPaths]}/meta.jsp"/>
> <put-attribute name="head" value="/WEB-INF/views/tiles/{options[defaultPaths]}/head.jsp"/>
> <put-attribute name="header" value="/WEB-INF/views/tiles/{options[defaultPaths]}/header.jsp"/>
> <put-attribute name="menu" value="/WEB-INF/views/tiles/{options[defaultPaths]}/menu.jsp"/>
> <put-attribute name="body" value="/WEB-INF/views/tiles/{options[defaultPaths]}/body.jsp"/>
>
> <put-attribute name="onReady" value="/WEB-INF/views/tiles/layouts/ace/onReady.jsp" />
> <put-attribute name="onReadyJs" value="/WEB-INF/views/tiles/{options[defaultPaths]}/onReady.js" />
>
> <put-list-attribute name="defaultPaths" cascade="true" >
> <add-attribute value="{1}"/>
> <add-attribute value="default"/>
> </put-list-attribute>
> </definition>
No - I haven't done much debugging other than the basics. I've been having other problems trying to get tiles to do what I want but having trouble
figuring stuff out. For the moment, just renamed onReady.js to onReady.js.jsp and it is working as expected. Will post back once I get some more info.
> Also have you tried naming the template in the second definition something other than "onReady".
No.
> Or have you any logging errors you can provide?
Strangely - no. I have tiles logger set to debug, but nothing shows up. Perhaps will have to try it out with Trace logging enabled.
Tx,
Eric
Re: Trying to us JS files as templates/attributes in JSP files but
not processing properly
Posted by Mick Semb Wever <mc...@apache.org>.
ClamAV 0.96.5
> <definition name="REGEXP:([^.]+)" template="/WEB-INF/views/tiles/layouts/ace/default.jsp" preparer="testPreparer">
> <put-attribute name="meta" value="/WEB-INF/views/tiles/{options[defaultPaths]}/meta.jsp"/>
> <put-attribute name="head" value="/WEB-INF/views/tiles/{options[defaultPaths]}/head.jsp"/>
> <put-attribute name="header" value="/WEB-INF/views/tiles/{options[defaultPaths]}/header.jsp"/>
> <put-attribute name="menu" value="/WEB-INF/views/tiles/{options[defaultPaths]}/menu.jsp"/>
> <put-attribute name="body" value="/WEB-INF/views/tiles/{options[defaultPaths]}/body.jsp"/>
>
> <put-attribute name="onReady" value=".page.onReady//{options[defaultPaths]}" />
>
> <put-list-attribute name="defaultPaths" cascade="true" >
> <add-attribute value="{1}"/>
> <add-attribute value="default"/>
> </put-list-attribute>
> </definition>
>
>
> <definition name="REGEXP:^\.page\.onReady//(.+)" template="/WEB-INF/views/tiles/layouts/ace/onReady.jsp">
> <put-attribute name="onReady" value="/WEB-INF/views/tiles/{1}/onReady.js" />
> </definition>
For testing sake, does it work ok if you collapse these definitions
together into just…
<definition name="REGEXP:([^.]+)" template="/WEB-INF/views/tiles/layouts/ace/default.jsp" preparer="testPreparer">
<put-attribute name="meta" value="/WEB-INF/views/tiles/{options[defaultPaths]}/meta.jsp"/>
<put-attribute name="head" value="/WEB-INF/views/tiles/{options[defaultPaths]}/head.jsp"/>
<put-attribute name="header" value="/WEB-INF/views/tiles/{options[defaultPaths]}/header.jsp"/>
<put-attribute name="menu" value="/WEB-INF/views/tiles/{options[defaultPaths]}/menu.jsp"/>
<put-attribute name="body" value="/WEB-INF/views/tiles/{options[defaultPaths]}/body.jsp"/>
<put-attribute name="onReady" value="/WEB-INF/views/tiles/layouts/ace/onReady.jsp" />
<put-attribute name="onReadyJs" value="/WEB-INF/views/tiles/{options[defaultPaths]}/onReady.js" />
<put-list-attribute name="defaultPaths" cascade="true" >
<add-attribute value="{1}"/>
<add-attribute value="default"/>
</put-list-attribute>
</definition>
Also have you tried naming the template in the second definition something other than "onReady".
Or have you any logging errors you can provide?
~mck
--
"Every nonfree program has a lord, a master -- and if you use the
program, he is your master." Richard Stallman
| http://github.com/finn-no | http://tech.finn.no |