You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by William Salvucci <Wi...@dn.netl.doe.gov> on 2003/06/20 19:43:38 UTC
[tiles] programatically putting a definition into a layout
with the following tiles-def, I can forward to layout.main and everything is fine:
definition name="layout.main" path="/layoutMain.jsp">
<put name="header" value="header.jsp" />
<put name="app" value="layout.app" />
<put name="footer" value="footer.jsp" />
</definition>
<definition name="layout.app" path="/layoutApp.jsp">
<put name="mainMenu" value="menu.main" />
<put name="subMenu" value="subMenu.jsp" />
<put name="body" value="welcome.jsp" />
</definition>
<!-- Menu bar definition -->
<definition name="menu.main" path="/menu.jsp" >
<putList name="items" >
<add value="Item 1" />
<add value="Item 2" />
<add value="Item 3" />
</putList>
</definition>
I then modify the tiles-def so that in layout.main app = "logon.jsp" where logon.jsp submit is associated with a struts action. In the struts action I set the layout.main app = "layout.app"
ComponentDefinition layout = TilesUtil.getDefinition("layout.main", request, this.servlet.getServletContext());
layout.put("app", "layout.app");
and forward to "layout.main". So basically after the action everything should be the same as my original setup. However, I get the following error on the forward
<Jun 20, 2003 1:16:00 PM EDT> <Error> <HTTP> <Included resource or file "/netl-c
ommons/layout.app" not found from requested resource "/netl-commons/layoutMain.j
sp".>
layoutMain.jsp is not changed during my update and looks like
<TABLE border="1">
<TR><TD COLSPAN="2"><tiles:insert attribute="header"/></TD></TR>
<TR><TD COLSPAN="2"><tiles:insert attribute="app" /> </TD></TR>
<TR><TD COLSPAN="2"><tiles:insert attribute="footer"/></TD></TR>
</TABLE>
Any idea why layoutMain.jsp could load layout.app in the original, but can't when I programatically put it into layout.main? I noticed that the put method doesn't have type as an argument for specifying "string", "page", "definition", so I hope that isn't it.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [tiles] programatically putting a definition into a layout
Posted by Cedric Dumoulin <ce...@apache.org>.
William Salvucci wrote:
>with the following tiles-def, I can forward to layout.main and everything is fine:
>
>definition name="layout.main" path="/layoutMain.jsp">
> <put name="header" value="header.jsp" />
> <put name="app" value="layout.app" />
> <put name="footer" value="footer.jsp" />
> </definition>
>
> <definition name="layout.app" path="/layoutApp.jsp">
> <put name="mainMenu" value="menu.main" />
> <put name="subMenu" value="subMenu.jsp" />
> <put name="body" value="welcome.jsp" />
> </definition>
>
> <!-- Menu bar definition -->
><definition name="menu.main" path="/menu.jsp" >
> <putList name="items" >
> <add value="Item 1" />
> <add value="Item 2" />
> <add value="Item 3" />
> </putList>
></definition>
>
>I then modify the tiles-def so that in layout.main app = "logon.jsp" where logon.jsp submit is associated with a struts action. In the struts action I set the layout.main app = "layout.app"
>
>ComponentDefinition layout = TilesUtil.getDefinition("layout.main", request, this.servlet.getServletContext());
> layout.put("app", "layout.app");
>
>
It is not recommended to change a definition dynamically, unless you
know very well what you do. A definition content is shared by all the
website. Changing the content will be reflected to all user of the
definition. If you want to change a definition attribute for the current
tiles, you should do so in the tile context, which hold a temporary copy
of the definition.
>and forward to "layout.main". So basically after the action everything should be the same as my original setup. However, I get the following error on the forward
>
><Jun 20, 2003 1:16:00 PM EDT> <Error> <HTTP> <Included resource or file "/netl-c
>ommons/layout.app" not found from requested resource "/netl-commons/layoutMain.j
>sp".>
>
>
The layout.app name has been interpreted as an URL. It appear that
the Tiles mechanism hasn't catch it.
I don't see how you call the action from the logon.jsp page.
Cedric
>layoutMain.jsp is not changed during my update and looks like
>
><TABLE border="1">
> <TR><TD COLSPAN="2"><tiles:insert attribute="header"/></TD></TR>
> <TR><TD COLSPAN="2"><tiles:insert attribute="app" /> </TD></TR>
> <TR><TD COLSPAN="2"><tiles:insert attribute="footer"/></TD></TR>
></TABLE>
>
>Any idea why layoutMain.jsp could load layout.app in the original, but can't when I programatically put it into layout.main? I noticed that the put method doesn't have type as an argument for specifying "string", "page", "definition", so I hope that isn't it.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org