Hi, Just a follow question to a similar scenario, what's the recomended approach with Struts-Tiles to handle the different modes in which a JSP may be displayed. i.e. Add/Edit/View especially for say a JSP page which has multiple sections.
e.g. Dish.jsp which can be composed of multiple sections, such as summary.jsp, picture.jsp, ingredients.jsp, preparation.jsp, cost.jsp Here are the approaches I can think of:- 1. Tile Definition say "dish.content" which has all the JSPs inserts for the "dish.jsp" page, and each section's (summary/picture/ingredients/preparation/cost) JSP expectinig some request attribute say "mode" to determine how to display that individual section in Add or Edit or View mode. <definition name="main.dish" path="/jsp/layout/classicLayout.jsp"> <put name="header" value="/jsp/dish/header_dish.jsp"/> <put name="body" value="dish.content"/> </definition> <definition name="dish.content" path="/jsp/layout/columnsLayout.jsp"> <put name="numCols" value="1" /> <putList name="list0" > <add value="/jsp/dish/summary.jsp" /> <add value="/jsp/dish/picture.jsp" /> <add value="/jsp/dish/ingredients.jsp" /> <add value="/jsp/dish/preparation.jsp" /> <add value="/jsp/dish/cost.jsp" /> </putList> </definition> And say in the "DishAction" class doing the forward to the tiles definition say "main.dish" and passing the request attribute say "mode" having value "edit", "view" and so on... 2. Having the JSP pages for each section split further as separate JSPs for each mode.... say summary_add.jsp, summary_edit.jsp, summary_view.jsp and using multiple tile definitions having the same layout!!! such as below:- <definition name="main.dish.edit" path="/jsp/layout/classicLayout.jsp"> <put name="header" value="/jsp/dish/header_dish_edit.jsp"/> <put name="body" value="dish.content.edit"/> </definition> <definition name="main.dish.view" path="/jsp/layout/classicLayout.jsp"> <put name="header" value="/jsp/dish/header_dish_view.jsp"/> <put name="body" value="dish.content.view"/> </definition> <definition name="dish.content.edit" path="/jsp/layout/columnsLayout.jsp"> <put name="numCols" value="1" /> <putList name="list0" > <add value="/jsp/dish/summary_edit.jsp" /> <add value="/jsp/dish/picture_edit.jsp" /> <add value="/jsp/dish/ingredients_edit.jsp" /> <add value="/jsp/dish/preparation_edit.jsp" /> <add value="/jsp/dish/cost_edit.jsp" /> </putList> </definition> <definition name="dish.content.view" path="/jsp/layout/columnsLayout.jsp"> <put name="numCols" value="1" /> <putList name="list0" > <add value="/jsp/dish/summary_view.jsp" /> <add value="/jsp/dish/picture_view.jsp" /> <add value="/jsp/dish/ingredients_view.jsp" /> <add value="/jsp/dish/preparation_view.jsp" /> <add value="/jsp/dish/cost_view.jsp" /> </putList> </definition> And the having the "DishAction" class forward to appropriate tiles definition "main.dish.edit" or "main.dish.view"..but in this case we are duplicating the Tile definitions even though the page layout is exactly the same!!!!!!! Any thoughts/comments/suggestions are most welcome. Thanks in advance!, Regards, Dharmendra ps: have a good day! -----Original Message----- From: Michael Rasmussen [mailto:[EMAIL PROTECTED] Sent: Friday, August 26, 2005 11:37 AM To: Struts Users Mailing List Subject: Re: Struts-Tiles Design question Dilip, The tiles controller sounds like an interesting way to do it, but I have never used it. I agree with Nels that you should stay away from a JSP implementation of this. I have stretched tiles pretty far as to what it can do conditionally, and I have been very happy with it. I would suggest using an action to make decisions about where to go, and use tiles templates to put the right fragments in the right places. Michael On 8/25/05, Nels Overgaard-Cook <[EMAIL PROTECTED]> wrote: > If you put the business logic in the JSPs, then it seems to me that you're > essentially mixing the business and presentation layers. I would put the > business login in an action and figure out which tile to forward to from > there. Of course, I haven't used the Tiles Controller that Greg suggested... > > Nels > > On 8/25/05, Dilip Ladhani <[EMAIL PROTECTED]> wrote: > > > > I have an application built on struts and tiles. I have a design question > > and would like some of your valuable opinions. > > > > I have a huge jsp, which is broken into many includes, say abc.jsp and > > includes one.jsp, two.jsp etc. > > As, I mentioned I use tiles so in the config file, I have a forward > > element, > > which is like this > > <forward name="abc" path="abc" contextRelative="true"/> > > > > The "abc" is defined in the tiles as > > <put name="body-content" value="/abc.jsp" /> > > > > Now for the design question... > > I am going to have to switch the includes (one.jsp, two.jsp etc) based on > > some business rules like the geographical area, app type etc. > > > > 1) Should I just put this logic in the jsp (using if statements like :if > > apptype = "A" use one.jsp else use one-next.jsp etc) or > > 2)Should I use tiles by having different action mappings based on > > different > > business parameters(say app type) and have each mapping forward to a > > different "forward" defined in tiles-def. > > > > Also the business parameters (based on which jsp is selected) may change > > in > > the future. > > > > Thanks for your input > > > > > > > > --------------------------------------------------------------------- > > 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] Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]