You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bill Holloway <bi...@gmail.com> on 2008/03/18 19:20:17 UTC

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Passing a component to layout

Posted by Howard Lewis Ship <hl...@gmail.com>.
<t:if test="false"> can be replaced by <t:block>.  An annoymous block
never renders and is used to prevent the rendering of its contents.

On Tue, Mar 18, 2008 at 11:40 AM, Martin Kersten
<Ma...@mercateo.com> wrote:
> 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:bill.holloway@gmail.com]
>  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: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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


AW: T5: Passing a component to layout

Posted by Martin Kersten <Ma...@mercateo.com>.
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:bill.holloway@gmail.com] 
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


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