It's not that much to say about it, the example is quite straight forward. Just point the definition path to a struts action which will, based upon some condition, forward to a page or other tile that will be used as the path for the definition and extended definitions.
So here's some examples of my tiles:
<!-- Main -->
<definition name="com.acme.web.search.tiles.main" path="/search/setupTiles.do">
<put name="content" value="OVERRIDE THIS" />
<put name="title" value="Search available domains" />
</definition>
<!-- Template definition for site layout 1 -->
<definition name="com.acme.web.search.tiles.main.acme" path="/front/tiles/tiles_front_main.jsp">
<put name="content" value="OVERRIDE THIS" />
<put name="title" value="Search layout 1" />
</definition>
<!-- Template definition for yr -->
<definition name="com.acme.web.search.tiles.main.yr" path="/search/tiles/tiles_front_yrse.jsp">
<put name="content" value="OVERRIDE THIS" />
<put name="title" value="Search layout 2" />
</definition>
<definition name="com.acme.web.search.tiles.search" extends="com.acme.web.search.tiles.main">
<put name="content" value="/search/pages/search.jsp" />
</definition>
And struts-config
<action path="/setupTiles" type="com.acme.web.search.actions.SetupTilesAction"> <forward name="acme" path="com.nictrade.web.search.tiles.main.acme" /> <forward name="yr" path="com.nictrade.web.search.tiles.main.yr" /> </action>
And com.acme.web.search.actions.SetupTilesAction
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) { // Do some conditional logic here to determine layout return mapping.findForward( "yr" ); }
Is this the information you wanted?, if so I hope it helps.
/Andreas
Benedict, Paul C wrote:
Andreas,
This is a wild solution. I don't understand page 15 and I've used Tiles before, but not in this way. Could you explain it?
-----Original Message-----
From: Andreas Toom [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 10, 2005 1:58 AM
To: Struts Users Mailing List
Subject: Re: Multiple tiles layouts for single application
Hello again, great pdf there, solved my problem nice and easy. Instead of a jsp in the path attribute of a definition I used a struts action which forwards to the right template, should work really nice.
Thank you very much for the help!
/Andreas
Allistair Crossley wrote:
http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf
page 15 may help you
Cheers.
-----Original Message----- From: Andreas Toom [mailto:[EMAIL PROTECTED] Sent: 09 May 2005 15:33 To: Struts Users Mailing List Subject: Re: Multiple tiles layouts for single application
Yes, but a tile definition is just a.. tile definition. All my definitions extends a base tile:
<definition name="com.acme.web.search.tiles.main" path="/front/tiles/tiles_front_main.jsp">
<put name="content" value="OVERRIDE THIS" />
<put name="title" value="Search here" />
</definition>
<definition name="com.acme.web.search.tiles.search" extends="com.acme.web.search.tiles.main">
<put name="content" value="/search/pages/search.jsp" />
</definition>
And my forwards are:
<forward name="success" path="com.acme.web.search.tiles.search" /> <forward name="failure" path="com.acme.web.search.tiles.error" />
So now, if a request has been made to http://mysite/?layout=layout1 or whatever it seems like a nice solution not have to change anything in my action configuration and instead have a filter/extension of a controller indicating which tile definitions to use, is this possible? or do I have to add a action-mapping/forward for each new site I want enable this search functionality?
As I sad before, the main problem as I see it is the input parameter in form validation, I guess I could solve it with some action in the input parameter instead, but all those solutions feel ugly and leaves me with much work if anything is about to change..
Any other ideas? :)
/Andreas
Allistair Crossley wrote:
Your requests should be routing through a Struts Controller
via an ActionMapping, and therefore your Action can examine the request and return the appropriate view which will be a forward to the tile definition of your choice.
Cheers, Allistair.
-----Original Message----- From: Andreas Toom [mailto:[EMAIL PROTECTED] Sent: 09 May 2005 15:05 To: user@struts.apache.org Subject: Multiple tiles layouts for single application
Hello, is there a way to switch tiles layout in an applaction depending on let's say request url. I have a struts-based application with a single purpose and I want to share this functionality with other php-based sites that my company have.
So if a request comes in to the site I want different layouts, each matching the calling site, for example:
http://myhost/myapp/ <- Original layout http://myhost/myapp/site1 <- Site1 layout http://myhost/myapp/site2 <- Site2 layout
The reason I wan't this is because I don't want do duplicate any action mappings in my struts-config. The major problem is form validation, since the input is just a simple tile definitions the app has no way to determine which layout to use. So if I had tiles-defs.xml, tiles-defs-site1.xml tiles-defs-site2.xml and a way to tell struts when to use which definition I figure the problem would be solved...
Is there a way to solve this without extending the request
processor/
tiles plugin?, if not can anyone point me in a good start direction?
Any ideas appreciated.
/Andreas
------------------------------------------------------------
---------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> -------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com">www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>
---------------------------------------------------------------------
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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. ------------------------------------------------------------------------------
--------------------------------------------------------------------- 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]