How can I incorporate the tiles definition into struts-config.xml? or How to define selectBodyTile.do in struts-config.xml?
<tiles:insert definition="erp.mainLayout" flush="true" controller="/selectBodyTile.do"/> <action path="/login" type="com.security.user.LoginAction" name="loginForm" scope="request" validate="true" input="/Login.jsp"> <forward name="success" path="/SecurityMaint.jsp"/> <forward name="failure" path="/Login.jsp"/> <forward name="cancel" path="/Welcome.jsp"/> </action> On Mon, 11 Oct 2004 17:49:55 +0100, Nigel Barrett <[EMAIL PROTECTED]> wrote: > You can also use a controller class/action to do it > > <tiles:insert definition="erp.mainLayout" flush="true" > controller="/selectBodyTile.do"/> > > and then in the action class for /selectBodyTile.do you can access the > ComponentContext which will allow you to change the attributes before tiles > does the insert thus allowing you to programmatically set the inner tile to > be a JSP,another tile, etc. of your choice. > > class SelectBodyControllerAction extends Action { > public ActionForward execute( ActionMapping mapping, > ActionForm form, > HttpServletRequest request, > HttpServletResponse response) > throws Exception { > > ComponentContext temp = > ComponentContext.getContext(request); > > if(isFullMoon(request)) { > temp.putAttribute("body", "fullmoon.jsp"); > } else { > temp.putAttribute("body", "justanotherday.jsp"); > } > > return super.execute(mapping, form, request, response); > } > } > > Controllers can also be a Derivative of TilesController which gives you the > Context as a param > > "Bj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > > you can use java to do this. For exemple, if you pass the boby url in > > request parameter. > > > > <% > > String contentUrl = request.getParameter("contentUrl"); > > if (contentUrl == null ) contentUrl = "/defaultContentUrl.jsp" > > %> > > > > <tiles:insert definition="erp.mainLayout" flush="true"> > > <put name="body" value="<%=contentUrl%>" /> > > </tiles:insert> > > > > I hope there's a better way to do this (maybe through external tile xml > > configuration files ) but I've never tried. > > > > Bj > > > > PC Leung a écrit : > > > > > I am very new Tiles. > > > I just want the content layout to change > > > and keep header, footer and left menu unchanged. > > > > > > Is it right to change the value programmatically and how? > > > or > > > do it in another way? > > > > > > <tiles:insert definition="erp.mainLayout" flush="true"> > > > <put name="body" value="/xxx.jsp" /> > > > </tiles:insert> > > > > > > Thank you very much. > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]