Thanks, Geoff.  Love Jumpstart.  Sticking with my counsel on this one....just
doing a simple one-level menu, so pretty sure I nailed it, for now ;-)

I selected the unravel CSS 2.0 tabs since it makes CSS do all the
heavy-lifting.  Always a better approach, if feasible.  And the CSS itself
is "pure" with no imagery etc.   With "tabX" in the styles being replaced by
componentResourcs.getPageName() as the "alternate id mechanism" in the
unravel CSS 2.0 code, the polymorphism required in the component template
falls into place.  

Now, all the components and page classes involved are completely free of any
tabs related code, almost oblivious to the menu driving the application. 
Just importing the tabs.css into Layout.java in the usual manner.  Nothing
else there.  No request parameters, Environment push-pop etc needed anymore. 

Basically, all the magic happens within Layout.tml which can (thankfully)
pick up the pageName - and hence use it to conditionally style the page.  
Specifically, in the unravel CSS 2.0 code you would simply replace tabX with
your page names.  In the example below, Index replaces tab1, Products
replaces tab2, Library replaces tab3 etc...   


<body id="${prop:componentResources.pageName}">


<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
      xmlns:p="tapestry:parameter">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>Whatever</title>
    </head>
    
    <body id="${prop:componentResources.pageName}">
    
     <ul id="tabnav">
     
          <li class="Index"><t:pagelink page="index">Home</t:pagelink></li>
          <li class="Products"><t:pagelink
page="products">Products</t:pagelink></li>
          <li class="Library"><t:pagelink
page="library">Bibliography</t:pagelink></li>

         [etc...]
     
     </ul>
    
     <t:body/>
    
    </body>
</html>


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Can-Component-Template-be-Informed-by-Page-Class-tp5681397p5682662.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to