Rick, this is probably not the cleanest solution but it works for me. tiles-def.xml: <tiles-definitions> <definition name=".base" path="/templates/layout.jsp" > <put name="header" value="/templates/header.jsp"/> <put name="menu" value="/templates/menu.jsp"/> <put name="footer" value="/templates/footer.jsp"/> </definition> <definition name=".welcome" extends=".base" > <put name="title" value="title.welcome" /> <put name="content" value="/WEB-INF/form/welcome.jsp"/> </definition> <definition name=".login" extends=".base" > <put name="title" value="title.loginpage" /> <put name="content" value="/WEB-INF/form/login.jsp"/> </definition> </tiles-definitions>
layout.jsp: <head> <link rel=stylesheet type="text/css" href="<%=request.getContextPath()%>/templates/layout.css"/> <tiles:useAttribute id="title" name="title" /> <title> <bean:message key="${title}" scope="page"/> </title> <tiles:get name="header" /><!-- I only use header.jsp to add meta tags --> </head> <body> <center> <h1> <bean:message key="${title}.header" scope="page"/> </h1> </center> </body> ApplicationResources.properties: title.loginpage= System LOGIN PAGE title.loginpage.header=LOGIN PAGE Hopefully this help. Shed. -----Original Message----- From: Rick Reumann [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 25, 2005 12:27 To: Struts Users Mailing List Subject: Been a while sinced used Tiles... can someone help? Ok, the recent Tiles questions posts I had were in relation to how I can create dynamic titles/labels. For example I might have a layout definition that has a header.jsp and in that header I need provide a label for the user to view that could look like... "Welcome John Doe, we love your company Acme Incorporated" What I want to be able to do is set up in header.jsp a way to use the label that comes from the tiles definition, but also then can use the custom stuff I set up in the Action such as "John Doe" and "Acme Inc." What I was planning on doing is setting up generic vars to represent what could be substituted such as labelVarA = "JohnDoe", labelVarB = "Acme Incorporated" then I'd stuff them into Request scope as labelVarA, and labelVarB. greeting.message=Welcome {0}, we love your company {1} Then if I have in my definition: <tiles:insert page="mainLayout.jsp"> <tiles:put name="myLabel" value="greeting.message"/> <tiles:put name="header" value="header.jsp"/> ... </tiles:insert> Can I just do in my header.jsp?: <fmt:message key="${myLabel}"> <fmt:param value='${labelVarA}'/> <fmt:param value='${labelVarB}'/> <fmt:param value='${labelVarC}'/> <fmt:param value='${labelVarD}'/> </fmt:message> Overall, I'm having a difficult time grasping how you can create dynamic labels/titles. For example a main layout might look like... <html> <head><title> ???tiles insert so that this title might be partially dynamic so I can't just use <tiles:getAsString name="title"/> </title></head> <body> *** this header needs the dynamic capabilities as described above *** <tiles:insert attribute="header.jsp"/> <tiles:insert attribute="someBlock.jsp"/> <tiles:insert attribute="someOtherBlock.jsp"/> <tiles:insert attribute="content.jsp"/> <tiles:insert attribute="footer.jsp"/> </body> </html> I don't want to hard code the label/titles in my Action class (except for the relevant params needed.. ie in example above user name, comp name). I have to problem creating extra tiles definitions with label definitions but I'm not sure how to set the defintions up so that they can handle dynamic parameters? thanks -- Rick --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME cryptographic signature