I hope I am not walking a dead road but here is what I understood:

1. You have a side-bar
2. This side bar displays its content depending on the current page type
3. You would like to encapsulate your side bar.

----

Easiest solution I can think of is to dispose your side bar into sub 
components and configure your sidebar component within the page:

page.tml:
<t:sidebar show="search, weather, about"/>

(show-parameter specifies which sub-components to show)

sidebar.tml:

....
<t:if test="showSearch">
   <t:sidebar.search/>
</t:if>
....

Your Sidebar class must provide a way to parse the show and
to support the property showSearch:
like:

boolean getShowSearch() {
    return show.contains("search");
}

This would be a clean and simple approach you might find useful.


Cheers,

Martin (Kersten)

-----Ursprüngliche Nachricht-----
Von: Bill Holloway [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 18. März 2008 19:20
An: Tapestry users
Betreff: T5: Passing a component to layout

Sidebars in our application will change from page to page.  Normally, I'd just 
pass them from the page to the layout as a block defined in the page.  However, 
some sidebars will have forms whose events I'd like to trap within the sidebar. 
 Blocks can't do that of course.  So I want my sidebar to be a component that 
can trap the event.

I can do this by putting this on my page:

<t:layout sidebar="mySidebar">
...
<t:if test="false">
    <t:pageSpecificSidebar />
</t:if>
...
</t:layout>

Then in the page class, I can do @InjectComponent private Sidebar 
_pageSpecificSidebar; public Sidebar getMySidebar() {return _mySidebar; }.  
Another possibility is to have the <div id="sidebar"> in the page template 
rather than layout, but I'd rather keep the "sidebar" code in the layout.

I don't like having to use the <t:if> statement there to prevent the rendering 
of the sidebar in the page.  I'm sure there's a better way to do this.  
Suggestions?

Bill

---------------------------------------------------------------------
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]

Reply via email to