struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "List Mailbox" <cal...@holview.com>
Subject RE: problems with tiles:getAsString in nested tiles?
Date Tue, 02 Dec 2003 01:01:33 GMT
Noah>> you can add attributes to extended definitions and then extend them.
I have an example using that technique on my site:
http://www.calandva.com/holmansite/do/blog/blogging?date=20030711#094831

  <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="indexMain"   	value="/web/includes/index.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="crumbtitle2"    value="Level 2"/>
	  <put name="crumblink2"    value="do/AutoForward?forward=level2.pagedef"/>
	  <put name="pagename"	  value="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 to the extended definitions.

Let me know if I am off base.

Cal
www.calandva.com

-----Original Message-----
From: struts-user-return-100275-calvin=holview.com@jakarta.apache.org
[mailto:struts-user-return-100275-calvin=holview.com@jakarta.apache.org]On
Behalf Of Green, Noah
Sent: Friday, November 28, 2003 9:56 PM
To: 'Struts Users Mailing List'
Subject: RE: problems with tiles:getAsString in nested tiles?


Hi David,
I've experimented with the solution in the URL, and with the stuff mentioned
in the Monday posts.
I understand the explicit invocation concept, that is:

<tiles:insert ....>
        <tiles:put .... />
</tiles:insert>

Instead of:
        <tiles:get ...>

It took me awhile to get the solutions to work, but they now do.  What I was
missing at first was another piece of the puzzle, one that isn't really made
explicit in a lot of Tiles texts.  It has to do with extending Tiles
definitions.  The solutions didn't work until all the attributes I was using
were explicitly declared, even with empty values, in the root of the
definitions hierarchy.  So "extends" is kind of a misleading term,
especially for Java programmers - you can OVERRIDE attributes when you
extend a Tiles definition, but you can't ADD NEW attributes.  They must all
be mentioned in the base definition.


In other words, this is incorrect:

<definition name="base"         path="base.jsp">
        <put name="title"  value="" />
</definition>

<definition name="child"      extends="base">
        <put name="title"  value="Child" />
        <put name="body"         value="body.jsp"/>  <!-- Incorrect here,
cannot add a new attribute, only override -->
</definition>


While this would be correct:

<definition name="base"         path="base.jsp">
        <put name="title"  value="" />
        <put name="body"         value=""/>
</definition>

<definition name="child"      extends="base">
        <put name="title"  value="Child" />
        <put name="body"         value="body.jsp"/>
</definition>


I think you mention as much in one of your posts,
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=struts-user@jakarta.apac
he.org&msgNo=95557


It's important for people trained as Java programmers to realize that
"extends" in Tile definitions means something  very different from what it
means in Java.  Too bad that it does, it would be nice for things to be more
dynamic, but this would probably be very difficult to implement (essentially
you'd have to build polymorphism into the tile definitions factory.)

Please correct me if I'm just totally on the wrong track.


Thanks again for the help,
Noah



-----Original Message-----
From: David Friedman [mailto:humble@ix.netcom.com]
Sent: Friday, November 28, 2003 8:30 PM
To: Struts Users Mailing List
Subject: RE: problems with tiles:getAsString in nested tiles?


Noah,

We talked about this king of problem Monday.  Basically, this old post
describes a solution for you, which I got working Monday, btw:

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg61368.html

Regards,
David

-----Original Message-----
From: Green, Noah [mailto:noah.green@lehman.com]
Sent: Friday, November 28, 2003 8:11 PM
To: 'struts-user@jakarta.apache.org'
Subject: problems with tiles:getAsString in nested tiles?



Hi,
Sorry to bother you all, I've looked thru the archives and seen some similar
threads, but without any clear conclusions. I'm using a <tiles:getAsString .
. . > element in a nested tile, and I'm getting the following error:

ServletException in:/jsp/layout/mainLayout.jsp] Error - tag.getAsString :
attribute 'title' not found in context. Check tag syntax'

However, this same element works in a tile that is nested at the "top
level".


Here is my tiles-defs.xml:
   <definition name=".testpage"   path="/jsp/testpage.jsp">
      <put     name="title"  value=""/>
      <put     name="body"   value=""/>
   </definition>

   <definition name=".testpage.main"     extends=".testpage">
      <put     name="title"         value="This is my title" />
      <put     name="body"          value="/jsp/layout/mainLayout.jsp" />
   </definition>


Here is my testpage.jsp, where the <tiles:getAsString ....> does work:
  <html-el:html>
     <head>
        <title><tiles:getAsString name="title" /></title>
     </head>

     <body bgColor="white">
        <tiles:get name="body" />
     </body>
  </html-el:html>

Here is my mainLayout.jsp, where the <tiles:getAsString ...> is failing:
  <h2><tiles:getAsString name="title" /></h2>


The end result is that when I use a ForwardAction to go to ".testpage.main",

the <title> element in the page header is populated correctly, but the call
to populated the <h2> area fails with the exception.

Any help on why this is happening is much appreciated :-)

Thanks!
Noah



Noah Green
LEHMAN BROTHERS, Inc.
Fixed Income Analytics
email: noah.green@lehman.com
pager: ngreen_lehman@imcingular.com
work: 212.526.1689
cellular: 917.406.4930
fax: 646.758.2306



----------------------------------------------------------------------------
--
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient
of this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information
is complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



----------------------------------------------------------------------------
--
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient
of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information
is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message