Ok I'll try to explain the whole process. 1) Create your "TilesAction". For example, take this example class:
<snip> package foo.bar; public class MyAction extends org.apache.struts.tiles.actions.TilesAction { public ActionForward execute(ComponentContext componentContext, ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { String userRole; // Used to store the user role to analyze // Insert some code to get the user role. if (userRole.equals("TheBigBoss")) return actionMapping.findForward("menuForBoss"); else if (userRole.equals("PoorFellow")) return actionMapping.findForward("menuForFellow"); return actionMapping.findForward("default"); } } </snip> 2) Map the TilesAction in struts-config.xml You should make a thing like this: <snip> <action path="/myTilesAction" type="foo.bar.LoadCatalogueAction" name="myForm" scope="session"> <!-- The form bean name "myForm" depends on your needs --> <forward name="menuForBoss" path="myPage.menuForBoss" /> <forward name="menuForFellow" path="myPage.menuForFellow" /> <forward name="default" path="myPage.menuForEveryoneElse" /> </action> </snip> Notice that in the forward path there are tiles definition, but you could use normal path-to-jsp-page. 3) Map the tiles definition (only needed if you are using the tiles definitions in your forwards). <snip> <definition name="myPage.menuForBoss" path="/tiles/menuForBoss.jsp" /> <definition name="myPage.menuForFellow" path="/tiles/menuForFellow.jsp" /> <definition name="myPage.menuForEveryoneElse" path="/tiles/menuForEveryoneElse.jsp" /> </snip> 4) Modify your tiles definition for the page. (I am using your example) <definition name=".PartyPlace" path="/layouts/layout.jsp"> .. <put name="menu" value="/myTilesAction.do"/> .. </definition> 5) You did it! Bye and sorry for being late in this answer. Antonio Petrelli Leandro Melo wrote: >I'm not sure if i get it right, i still have a couple >doubts. >Take this definition: > ><definition name=".PartyPlace" >path="/layouts/layout.jsp"> >... > > <put name="menu" value="/chooseMenu.do"/> > >... > ></definition> > > >Naturally i got a login page, would i have to redirect >the login (or just forward the login) to this >"TilesAction" and then manipulate my definition and >insert the real jsp page i want??? > >I have never heard of this "TilesAction" (haven`t been >dealling with struts for long time), but is it >possible to some post some bib reference (or web >reference) where i can learn how to work with it??? > >If it`s easy, maybe a little piece of code would also >work. > >Thanks, >Leandro > > > > > > > > > > --- [EMAIL PROTECTED] escreveu: > >>think the best (and the most elegant) way to make >>dynamic tiles is by >>using TilesAction. This because this class has >>knowledge of the use of >>Tiles. >>So write your TilesAction (it is similar to a plain >>Action, except of some >>more parameters in the "execute" method). In the >>"execute" method put your >>code that can distinguish between different users >>and for each one forward >>to a different JSP page, that will be your "real" >>tile. >>Obviously map your actions in struts-config.xml just >>the same way as >>normal actions. >>Then put a definition like this (I am using your >>example): >> >><definition name=".PartyPlace" >>path="/layouts/layout.jsp"> >> <put name="title" value="PartyPlace"/> >> <put name="header" value="/common/header.jsp"/> >> <put name="menu" value="/common/menu.jsp"/> >> <put name="error" >>value="/functionalBlocks/errorHTMLcomponent.jsp"/> >> <put name="pageComment" >>value="/choosePageComment.do"/> >> <put name="body" value="/chooseBody.do"/> >> <put name="footer" value="/common/footer.jsp"/> >></definition> >> >>Hope it helps. >>Ciao >>Antonio >> >>P.S. In fact in this example a normal Action can be >>used, but I suggest to >>use TilesAction because that class can manipulate >>the definition itself >>(please people working on Struts, correct me if I am >>wrong). >> >>Leandro Melo wrote: >> >>>Hi, >>>i got a very ordinary problem. >>>I need to provide diferent menus for diferent >> >>people >> >>>that are logged in the application. >>>I don't know what i should do exactly to provide >> >>this >> >>>funcionality, because i don't really know what >> >>Tiles >> >>>allow me to do (i don't know it's potencial). >>> >>>I got the following base tiles definition in my >> >>app. >> >>><definition name=".PartyPlace" >>>path="/layouts/layout.jsp"> >>> <put name="title" value="PartyPlace"/> >>> <put name="header" value="/common/header.jsp"/> >>> <put name="menu" value="/common/menu.jsp"/> >>> <put name="error" >>>value="/functionalBlocks/errorHTMLcomponent.jsp"/> >>> <put name="pageComment" value="${pageComment}"/> >>> <put name="body" value="${body}"/> >>> <put name="footer" value="/common/footer.jsp"/> >>></definition> >>> >>>One thing i thought is to verify the user >> >>permissions >> >>>at log time, then, depending on the user i'd change >>>the attribute "menu" of my definition to the page >>>menu2.jsp or menu3.jsp, for example. Can (how) i do >>>that??? >>> >>>I also thought on bulding 2 (or 3 or 4) BASE >>>deifinitions and at log time i'd decide which base >>>definition to use. Can i do that (how??)?? >>> >>>I'd appreciate if some show me some reference or >> >>just >> >>>some sample code on how to do that. >>> >>>Thansk, >>>ltcmelo >>> >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]