Here you need to understand the api of tiles. It is quite powerful. I wrote something about this for internal use. I will paste it here:
// Read definition from factory, but we can create it here. ComponentDefinition definition = DefinitionsUtil.getDefinition(mapping.findForward("success").getPath(), request, getServlet().getServletContext()); // change the title attribute definition.putAttribute("title", "title"); DefinitionsUtil.setActionDefinition(request, definition); definition = DefinitionsUtil.getActionDefinition(request); //create a new component context -- required by ActionComponentServlet ComponentContext context = new ComponentContext(definition.getAttributes()); //set it into request ComponentContext.setContext(context,request); } catch (FactoryNotFoundException ex) { request.setAttribute("actionError", "Can't get definition factory."); return (mapping.findForward("failure")); } catch (NoSuchDefinitionException ex) { request.setAttribute("actionError", "Can't get definition test.layout.test1."); return (mapping.findForward("failure")); } catch (DefinitionsFactoryException ex) { request.setAttribute("actionError", "General error '" + ex.getMessage() + "'."); return (mapping.findForward("failure")); } catch (Exception e) { cat.debug("perform(): exception when loading definition: " + e); } // do not return null, because ActionComponentServlet will not trigger the forwarding which will read the definition from the context return mapping.findForward("success"); sorry if it is all messed up after the cut & paste. But the idea is that if you know what each layout has a parameters, you can simply replace the parameters dynamically in the perform() method. It is not hard to find out the parameters using the api. A more practical example would be the vertical box layout has a components parameter and you can just add items to this array list. The items can be jsp names or can be definition/component names. Shouldn't really use jsp names here for the same reason why struts doesn't hardcode them. I would reference definition/component names instead and centralize the descriptions in a layout xml definition file (tiles descriptor). Also note that this was just an attempt to get something to work and not necessarily the best approach. - Sandeep --- Darryl Pentz <[EMAIL PROTECTED]> wrote: > Cool. That's interesting. And you mentioned > something about being able to > manipulate placement of tiles from within the Action > class. How is that > done? > > - Darryl > > > -----Original Message----- > > From: Sandeep Takhar > [mailto:[EMAIL PROTECTED]] > > Sent: 01 November 2001 18:23 > > To: Struts Users Mailing List > > Subject: RE: Duplication of Template Files > Solution > > > > > > When I tested it (a very simple test) I used the > > following in the struts-config.xml file: > > > > <action path="/test/sandeepTestAction" > > > > > type="org.apache.struts.example.tiles.test.SandeepTestAction"> > > <forward name="success" path="doc.mainLayout"/> > > </action> > > > > Here was the tiles definition for the path > attribute > > above (it can be any definition): > > > > <definition name="doc.mainLayout" > > path="/layout/classicLayout.jsp"> > > <put name="title" value="Tiles Library > > Documentation" /> > > <put name="header" value="/common/header.jsp" > /> > > <put name="menu" value="doc.menu.main" /> > > <put name="footer" value="/common/footer.jsp" > /> > > <put name="body" value="doc.portal.body" /> > > </definition> > > > > I used the tiles-docs.war file for my testing. > > > > sorry if my cut & paste is all messed up. > > > > - Sandeep > > > > > > --- Darryl Pentz <[EMAIL PROTECTED]> wrote: > > > Sandeep, > > > > > > Can you post an example of a struts-config > mapping > > > using Tiles. I tried to > > > use Tiles but couldn't get it to run a page > twice. > > > In other words, I had a > > > search function which worked fine the first time > > > with Tiles, but when I > > > changed the search criteria and resubmitted, the > > > Action class ran, but when > > > it forwarded the result to the JSP, the > application > > > hung at the insert tag. > > > This is what prompted me to try the inline thing > > > with the original Struts > > > template tags and it worked, without any > changes, so > > > I deduced that Tiles is > > > buggy. I'm running Orion on Win2K with a nightly > > > build from about 10 days > > > ago. > > > > > > I didn't know about being able to reference the > > > Tiles definition from the > > > struts-config action mapping, hence my request > > > above. > > > > > > thanks, > > > Darryl > > > > > > > -----Original Message----- > > > > From: Sandeep Takhar > > > [mailto:[EMAIL PROTECTED]] > > > > Sent: 01 November 2001 18:05 > > > > To: Struts Users Mailing List > > > > Subject: Re: Duplication of Template Files > > > Solution > > > > > > > > > > > > man i suck, i did it again. > > > > > > > > finish the thought, than send the mail. > > > > > > > > ok -- what I meant was that unlike what your > > > initial > > > > e-implies: that tiles works exactly like > > > > template-tags, what I meant was that you can > > > create > > > > the duplicate definition in the xml file and > than > > > > reference this layout definition/component in > the > > > > action forward of a struts-config file. I > like > > > this > > > > solution better because you have clearly > defined > > > all > > > > the layouts and are just forwarding to the > correct > > > > one. > > > > > > > > This means that you don't need the duplicated > jsp > > > > which is a pain to maintain. So either > solution > > > (the > > > > one you described) and this one will get rid > of > > > that > > > > duplicate jsp. > > > > > > > > - Sandeep > > > > --- Sandeep Takhar <[EMAIL PROTECTED]> > > > wrote: > > > > > Tiles allows you to do this as well. > > > > > > > > > > btw: I have replied to another reply in this > > > same > > > > > thread about other things I like about > tiles. > > > In my > > > > > usual haste I deleted the original message > when > > > I > > > > > realized there was something more I wanted > to > > > say. > > > > > > > > > > - sandeep > > > > > --- Darryl Pentz <[EMAIL PROTECTED]> > wrote: > > > > > > I've discovered quite by accident that the > > > Struts > > > > > > templating framework > > > > > > allows me to eliminate duplication of my > JSP > > > pages > > > > > > by simply including the > > > > > > body page inline to the template > definition > > > page. > > > > > By > > > > > > this I mean I combine > > > > > > both pages into one as follows: > > > > > > > > > > > > <template:insert ...> > > > > > > <template:put name="header" ... /> > > > > > > <template:put name="nav" ... /> > > > > > > <template:put name="body" ... /> > > > > > > > > > > > > ... BODY HTML GOES HERE ... > > > > > > > > > > > > </template:put> > > > > > > </template:insert> > > > > > > > > > > > > I'd previously enquired on this list how I > > > could > > > > > > eliminate the duplication > > > > > > of the pages where the main body HTML > exists > > > in a > > > > > > separate JSP page that is > > > > > > simply referred to from the definition > file > > > i.e. > > > > > > <template:put name="body" > > > > > > content="/blah/blah/body.jsp"/>. Strangely > > > nobody > > > > > > responded with the above > > > > > > solution so I'm wondering is this simply a > > > > > > side-effect of the PutTag class > > > > > > or Craig, did you intend for it to work > this > > > way? > > > > > > I'm quite surprised I > > > > > > haven't seen this technique used in any of > the > > > > > > examples. Rather, the > > > > > > duplication is suggested. The new Tiles > > > extension > > > > > > allows the above which > > > > > > prompted me to try it with the Struts > template > > > tag > > > > > > library just for grins, > > > > > > and it worked! > > > > > > > === message truncated === __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>