RE: Tiles, Definition inheritence
Only the template definition called can 'see' the Tiles context and access the attributes. In your case the classicLayout.jsp can use the input and result attributes. If the bodyTwoColumns.jsp is to be your layout then changing classicLayout.jsp to have the two columns format would be the best solution. You could also pass the attributes from the template to the input jsps but that becomes difficult to extend or change because you have explicit variables you are creating in your template jsp for other jsps to use. Cal www.calandva.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Oliver Wulff Sent: Monday, December 08, 2003 6:16 AM To: [EMAIL PROTECTED] Subject: Tiles, Definition inheritence Hi I'm quite new to Tiles and I've got the following problem: I've defined the following default definition: definition name=.mainLayout path=/layout/classicLayout.jsp put name=title value=Berechtigung WEB with Tiles / put name=header value=/top_menu.jsp / put name=menu value=/toc.jsp / put name=footer value=/footer.jsp / put name=body value=/welcome.jsp / /definition The classicLayout.jsp hasn't been changed (Struts examples). Additionally, I've defined the following Definition: definition name=.showOrgEinheit extends=.mainLayout put name=input value=/getOrgEinheit.jsp / put name=result value=/showOrgEinheit.jsp / put name=body value=/layout/bodyTwoColumns.jsp / /definition The bodyTwoColumns looks like this: %@ taglib uri=/WEB-INF/struts-tiles.tld prefix=tiles % table border=0 width=100% cellspacing=5 tr td width=50% align=left tiles:insert attribute='input'/ /td td width=50% align=left tiles:insert attribute='result' / /td /tr /table My struts action forwards to the definition .showOrgEinheit but I get the following error: [ServletException in:/layout/bodyTwoColumns.jsp] Error - Tag Insert : No value found for attribute 'input'.' Can anybody help me, please? Thank you a lot. Cheers Oliver *** BITTE BEACHTEN *** Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet möglicherweise vertrauliche oder gesetzlich geschützte Daten oder Informationen. Zum Empfang derselben ist (sind) ausschliesslich die genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter Ausschluss jeder Reproduktion zu zerstören und die absendende Person umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe. - 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]
Antwort: RE: Tiles, Definition inheritence
Wouldn't it make sense that the inserted tiles has access to the tiles context either? I think, my requirement is quite common. I think that the main layout of a web application won't change but the body tile contains sometimes one tile or is splitted in an upper- and lower-part or a left- and a right-part. It's a little bit unhandy to copy the classicLayout.jsp to another layout jsp and add the input- and result-part. Therefore, layout code is duplicated. Does my requirement contradict the design of tiles? ** Oliver Wulff Zürich Versicherungs-Gesellschaft IA4, CoC Middleware Postfach, 8085 Zürich Telefon: +41- 1 628 58 07 Fax: +41 - 1 623 58 07 E-Mail: mailto:[EMAIL PROTECTED] List Mailbox [EMAIL PROTECTED]An: Struts Users Mailing List [EMAIL PROTECTED] om Kopie: Thema:RE: Tiles, Definition inheritence 08.12.2003 15:10 Bitte antworten an Struts Users Mailing List Only the template definition called can 'see' the Tiles context and access the attributes. In your case the classicLayout.jsp can use the input and result attributes. If the bodyTwoColumns.jsp is to be your layout then changing classicLayout.jsp to have the two columns format would be the best solution. You could also pass the attributes from the template to the input jsps but that becomes difficult to extend or change because you have explicit variables you are creating in your template jsp for other jsps to use. Cal www.calandva.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Oliver Wulff Sent: Monday, December 08, 2003 6:16 AM To: [EMAIL PROTECTED] Subject: Tiles, Definition inheritence Hi I'm quite new to Tiles and I've got the following problem: I've defined the following default definition: definition name=.mainLayout path=/layout/classicLayout.jsp put name=title value=Berechtigung WEB with Tiles / put name=header value=/top_menu.jsp / put name=menu value=/toc.jsp / put name=footer value=/footer.jsp / put name=body value=/welcome.jsp / /definition The classicLayout.jsp hasn't been changed (Struts examples). Additionally, I've defined the following Definition: definition name=.showOrgEinheit extends=.mainLayout put name=input value=/getOrgEinheit.jsp / put name=result value=/showOrgEinheit.jsp / put name=body value=/layout/bodyTwoColumns.jsp / /definition The bodyTwoColumns looks like this: %@ taglib uri=/WEB-INF/struts-tiles.tld prefix=tiles % table border=0 width=100% cellspacing=5 tr td width=50% align=left tiles:insert attribute='input'/ /td td width=50% align=left tiles:insert attribute='result' / /td /tr /table My struts action forwards to the definition .showOrgEinheit but I get the following error: [ServletException in:/layout/bodyTwoColumns.jsp] Error - Tag Insert : No value found for attribute 'input'.' Can anybody help me, please? Thank you a lot. Cheers Oliver *** BITTE BEACHTEN *** Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet möglicherweise vertrauliche oder gesetzlich geschützte Daten oder Informationen. Zum Empfang derselben ist (sind) ausschliesslich die genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter Ausschluss jeder Reproduktion zu zerstören und die absendende Person umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe. - 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] *** BITTE BEACHTEN *** Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet möglicherweise vertrauliche oder gesetzlich geschützte Daten oder Informationen. Zum Empfang derselben ist (sind) ausschliesslich die genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter Ausschluss jeder Reproduktion zu zerstören und die absendende Person umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe
RE: Tiles, Definition inheritence
This is (IMHO) a classic issue with tiles. The Tiles meaning of 'inheritance' isn't quite the same as in Java or other OO concepts. Tiles inherit values from their parents, and can override those values. However, adding new values is not supported. The only way [that I've found, anway] that you can support the addition of new properties is to use the tiles importAttribute tag (see http://jakarta.apache.org/struts/userGuide/struts-tiles.html#importAttribute ) in the main layout JSP, i.e. /layout/classicLayout.jsp, to pass the values into a scope where they can be found by other tags such as bean:write and use the values that way. David Hibbs, ACS Staff Programmer / Analyst American National Insurance Company -Original Message- From: Oliver Wulff [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 5:16 AM To: [EMAIL PROTECTED] Subject: Tiles, Definition inheritence Hi I'm quite new to Tiles and I've got the following problem: I've defined the following default definition: definition name=.mainLayout path=/layout/classicLayout.jsp put name=title value=Berechtigung WEB with Tiles / put name=header value=/top_menu.jsp / put name=menu value=/toc.jsp / put name=footer value=/footer.jsp / put name=body value=/welcome.jsp / /definition The classicLayout.jsp hasn't been changed (Struts examples). Additionally, I've defined the following Definition: definition name=.showOrgEinheit extends=.mainLayout put name=input value=/getOrgEinheit.jsp / put name=result value=/showOrgEinheit.jsp / put name=body value=/layout/bodyTwoColumns.jsp / /definition The bodyTwoColumns looks like this: %@ taglib uri=/WEB-INF/struts-tiles.tld prefix=tiles % table border=0 width=100% cellspacing=5 tr td width=50% align=left tiles:insert attribute='input'/ /td td width=50% align=left tiles:insert attribute='result' / /td /tr /table My struts action forwards to the definition .showOrgEinheit but I get the following error: [ServletException in:/layout/bodyTwoColumns.jsp] Error - Tag Insert : No value found for attribute 'input'.' Can anybody help me, please? Thank you a lot. Cheers Oliver *** BITTE BEACHTEN *** Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet möglicherweise vertrauliche oder gesetzlich geschützte Daten oder Informationen. Zum Empfang derselben ist (sind) ausschliesslich die genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter Ausschluss jeder Reproduktion zu zerstören und die absendende Person umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Antwort: RE: Tiles, Definition inheritence
BDY.RTF Description: RTF file - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tiles, Definition inheritence
The issue that keeps coming up is the ability for jsps other than the page= (template) jsp to have access to the attributes. John provided a good technique using a second definition. As to the definitions and the template's ability to access attributes - you can add attributes to extended definitions and then extend them. I have an example app using that technique on my site: http://www.calandva.com/holmansite/do/blog/blogging?date=20030711#094831 In this app I access the Tiles Context in an action and in a tag to modify the attributes on the fly. In the advanced pdf Cedric provides an example of creating the number of columns in the body of a template on the fly. definition name=home.pagedef page=/template.jsp controllerUrl=/do/renderCrumb put name=title value=home.title / put name=headervalue=/web/includes/header.jsp / put name=index value=/web/pages/home/HomeIndex.jsp / put name=content value=/web/pages/home/HomeContent.jsp / put name=footervalue=/web/includes/footer.jsp / put name=styleSheetvalue=web/styles/Grey_StyleSheet.css / put name=keywords value=home.keywords/ put name=crumbsvalue=/web/includes/crumb.jsp/ put name=crumbtitle1 value=Home/ put name=crumblink1value=do/AutoForward?forward=home.pagedef/ put name=pagename value=home/ /definition definition name=level2.pagedef extends=home.pagedef put name=title value=level2.title / put name=indexvalue=/web/pages/level2/Level2Index.jsp / put name=content value=/web/pages/level2/Level2Content.jsp / put name=keywords value=level2.keywords/ put name=crumbtitle2value=Level 2/ put name=crumblink2value=do/AutoForward?forward=level2.pagedef/ put name=pagenamevalue=level2/ /definition definition name=level3.pagedef extends=level2.pagedef put name=title value=level3.title / put name=indexvalue=/web/pages/level3/Level3Index.jsp / put name=contentvalue=/web/pages/level3/Level3Content.jsp / put name=crumbtitle3 value=Level 3/ put name=crumblink3 value=do/AutoForward?forward=level3.pagedef/ put name=pagename value=level3/ /definition When the level3.pagedef is used the template.jsp has access to all three levels of crumbtitle values. Some attributes are overridden and others are added as the definitions are extended. Any attribute you add in the extended path is available to the extended template. Let me know if I am off base. Cal www.calandva.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Hibbs, David Sent: Monday, December 08, 2003 10:12 AM To: 'Oliver Wulff'; [EMAIL PROTECTED] Subject: RE: Tiles, Definition inheritence This is (IMHO) a classic issue with tiles. The Tiles meaning of 'inheritance' isn't quite the same as in Java or other OO concepts. Tiles inherit values from their parents, and can override those values. However, adding new values is not supported. The only way [that I've found, anway] that you can support the addition of new properties is to use the tiles importAttribute tag (see http://jakarta.apache.org/struts/userGuide/struts-tiles.html#importAttribute ) in the main layout JSP, i.e. /layout/classicLayout.jsp, to pass the values into a scope where they can be found by other tags such as bean:write and use the values that way. David Hibbs, ACS Staff Programmer / Analyst American National Insurance Company -Original Message- From: Oliver Wulff [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 5:16 AM To: [EMAIL PROTECTED] Subject: Tiles, Definition inheritence Hi I'm quite new to Tiles and I've got the following problem: I've defined the following default definition: definition name=.mainLayout path=/layout/classicLayout.jsp put name=title value=Berechtigung WEB with Tiles / put name=header value=/top_menu.jsp / put name=menu value=/toc.jsp / put name=footer value=/footer.jsp / put name=body value=/welcome.jsp / /definition The classicLayout.jsp hasn't been changed (Struts examples). Additionally, I've defined the following Definition: definition name=.showOrgEinheit extends=.mainLayout put name=input value=/getOrgEinheit.jsp / put name=result value=/showOrgEinheit.jsp / put name=body value=/layout/bodyTwoColumns.jsp / /definition The bodyTwoColumns looks like this: %@ taglib uri=/WEB-INF/struts-tiles.tld prefix=tiles % table border=0 width=100% cellspacing=5 tr td width=50% align=left tiles:insert attribute='input'/ /td td width=50% align=left tiles:insert attribute='result' / /td /tr /table My struts
RE: Tiles, Definition inheritence
BDY.RTF Description: RTF file - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tiles, Definition inheritence
Gotcha - actually no jsp has access but the template at any level - so even the jsps defined at the highest level in my case header.jsp do not have access. Tiles uses the Tiles Context - not the page (which would not work either), request, session, or application - so only the template has access to the attributes.. If I need to modify the layout or modify an attribute based on runtime factors I use the controllerURL to get a handle on the Tiles Context and modify it prior to the jsp getting the page - I also stuff a few common attributes into request scope at the same time so all the jsps can have access - to things like the definition being rendered. Cal www.calandva.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Monday, December 08, 2003 2:23 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Tiles, Definition inheritence I think the problem that Oliver was having (expressed through your example) was that the webpage defined by level3.pagedef.content (/web/pages/level3/Level3Content.jsp) could not access attributes defined in the same context (for example, level3.pagedef.index (/web/pages/level3/Level3Index.jsp). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, December 08, 2003 12:11 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Tiles, Definition inheritence The issue that keeps coming up is the ability for jsps other than the page= (template) jsp to have access to the attributes. John provided a good technique using a second definition. As to the definitions and the template's ability to access attributes - you can add attributes to extended definitions and then extend them. I have an example app using that technique on my site: http://www.calandva.com/holmansite/do/blog/blogging?date=20030711#094831 In this app I access the Tiles Context in an action and in a tag to modify the attributes on the fly. In the advanced pdf Cedric provides an example of creating the number of columns in the body of a template on the fly. definition name=home.pagedef page=/template.jsp controllerUrl=/do/renderCrumb put name=title value=home.title / put name=header value=/web/includes/header.jsp / put name=index value=/web/pages/home/HomeIndex.jsp / put name=content value=/web/pages/home/HomeContent.jsp / put name=footer value=/web/includes/footer.jsp / put name=styleSheet value=web/styles/Grey_StyleSheet.css / put name=keywords value=home.keywords/ put name=crumbs value=/web/includes/crumb.jsp/ put name=crumbtitle1 value=Home/ put name=crumblink1 value=do/AutoForward?forward=home.pagedef/ put name=pagename value=home/ /definition definition name=level2.pagedef extends=home.pagedef put name=title value=level2.title / put name=index value=/web/pages/level2/Level2Index.jsp / put name=content value=/web/pages/level2/Level2Content.jsp / put name=keywords value=level2.keywords/ put name=crumbtitle2value=Level 2/ put name=crumblink2 value=do/AutoForward?forward=level2.pagedef/ put name=pagenamevalue=level2/ /definition definition name=level3.pagedef extends=level2.pagedef put name=title value=level3.title / put name=index value=/web/pages/level3/Level3Index.jsp / put name=content value=/web/pages/level3/Level3Content.jsp / put name=crumbtitle3 value=Level 3/ put name=crumblink3 value=do/AutoForward?forward=level3.pagedef/ put name=pagename value=level3/ /definition When the level3.pagedef is used the template.jsp has access to all three levels of crumbtitle values. Some attributes are overridden and others are added as the definitions are extended. Any attribute you add in the extended path is available to the extended template. Let me know if I am off base. Cal www.calandva.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hibbs, David Sent: Monday, December 08, 2003 10:12 AM To: 'Oliver Wulff'; [EMAIL PROTECTED] Subject: RE: Tiles, Definition inheritence This is (IMHO) a classic issue with tiles. The Tiles meaning of 'inheritance' isn't quite the same as in Java or other OO concepts. Tiles inherit values from their parents, and can override those values. However, adding new values is not supported. The only way [that I've found, anway] that you can support the addition of new properties is to use the tiles importAttribute tag (see http://jakarta.apache.org/struts/userGuide/struts-tiles.html#importAttri bute ) in the main layout JSP, i.e. /layout/classicLayout.jsp, to pass the values into a scope where they can be found by other tags such as bean:write and use the values that way. David Hibbs, ACS Staff Programmer
RE : [Tiles] - Definition inheritence question
I have found a way to do this using an intermediate definition: definition name=plant_status_page extends=default_layout put name=body value=plant_status_body/ /definition definition name=plant_status_body extends=default_layout path=/jsp/status/plant_status_body.jsp /definition Plant_status_body.jsp: !-- Header Page Information -- tiles:insert definition=plant_list / HR tiles:insert definition=subsystem_list/ Therefore requesting plant_status_page gives me the page I want. If I request plant_status_body directly, I don't get the nested behavior that I'm looking for (my page is missing the header footer). I'm not sure this is the cleanest approach, because there seems to be an extra definition (plant_status_page), but at the same time I'm not sure if there's a way to avoid it. Is there another way?? Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: [Tiles] - Definition inheritence question
Hi Michael, When you extend a definition, all attributes from ancestor are inherited, and then overloaded by attributes specified in the new definition. In your case, you overload the 'path' attribute with a new value, disguarding the previous value. The way to go is to have an intermediate tiles (you already have it: plant_status_body.jsp), and a definition using this tiles. Then you use the definition as body. Hope this help, Cedric Michael wrote: I've been playing with Tiles for several days, getting some simple examples to work. I've read all the documentation several times but I'm missing a key part of the definition inheritence I think. Can somebody please clarify this for me? Here's what I'd like to do: I'd like to have a main page that specifies a header, menubar, body, and footer. Then in the pages of my website, I'd like to insert tiles into the body. So far it's very easy if I only have one tile to insert into the body. But I'm really stuck on how to insert two tiles into the same body. This is what I've tried: tiles-defs.xml: !-- Doc index page description -- definition name=default_layout path=/jsp/layouts/default_layout.jsp put name=header value=/jsp/common/header.jsp / put name=menubar value=/jsp/common/menubar.jsp / put name=footer value=/jsp/common/footer.jsp / /definition definition name=plant_status_page extends=default_layout path=/jsp/status/plant_status_body.jsp put name=body1 value=plant_list/ put name=body2 value=subsystme_list/ /definition Default_layout.jsp: !-- Header Page Information -- tiles:insert attribute=header / !-- Menu Bar -- tiles:insert attribute=menubar/ !-- Main Body Information -- tiles:insert attribute=body/ !-- Copyright Information -- tiles:insert attribute=footer/ plant_status_body.jsp: HRTOPHR !-- Header Page Information -- tiles:insert attribute=body1 / HRMIDDLEHR tiles:insert attribute=body2/ HRENDHR This works, but the problem is I don't get the header footer defined in the default_layout.jsp. Now I can cut paste the header footer code into plant_status_body.jsp but I think there has to be a better way to do this. Can someone please tell me if this is possible and how? Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]