Extending Definitions

 < Day Day Up > 



It is often the case that several JSP pages use the same default parameters. Yet other pages use the same Tile layout but use different Tile parameters. Instead of creating a completely different definition, you can extend one definition to another definition by using the extends attribute. Here's an example:

   <definition name="siteLayoutDef3" path="/siteLayout3.jsp">     <put name="title" value="WROX Stock Quote System" />     <put name="header" value="/header2.jsp" />     <put name="footer" value="/footer.jsp" />     <put name="content" type="string">        Content goes here     </put>     <putList name="items" >       <item value="Home"             link="/index.html"  />       <item value="WROX"             link="http://www.wrox.com"  />       <item value="Trivera Technologies"             link="http://www.triveratech.com/"  />       <item value="Virtuas"             link="http://www.virtuas.com/"  />       <item value="Rick Hightower"             link="http://www.rickhightower.com"  />       <item value="Rick's Blog"             link="http://rickhightower.blogspot.com/"  />     </putList>   </definition>   <definition name="siteLayoutDef4" extends="siteLayoutDef3">     <put name="title" value="WROX Quote Sub System" />     <putList name="items" >       <item value="Home"             link="/index.html"  />       <item value="WROX"             link="http://www.wrox.com"  />       <item value="Trivera Technologies"             link="http://www.triveratech.com/"  />       <item value="Virtuas"             link="http://www.virtuas.com/"  />     </putList>   </definition>   <definition name="siteLayoutDef5" extends="siteLayoutDef4">     <putList name="items" >     </putList>   </definition>   <definition name="siteLayoutDef6" path="/siteLayout4.jsp"               extends="siteLayoutDef4">   </definition> 

Note that siteLayoutDef4 extends siteLayoutDef3, overrides the title values, and defines a shorter navigation list. It inherits all the other parameters from siteLayoutDef3 that it did override—header, footer, and content. Also note that siteLayoutDef5 extends siteLayout4, except it blanks out the list of items. A definition inherits all of the attributes of its super definition and all of its super definition's super definitions ad infinitum.

In addition to overriding attributes, you can change the Tile layout JSP. Look at siteLayoutDef6; it extends siteLayoutDef5 and specifies a new Tile layout (siteLayout4.jsp).



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net