You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Yann Ramin <at...@stackworks.net> on 2007/04/10 08:28:43 UTC

T5: Best page templating strategy

I'm using T5 to do some experimental testing, creating some mockup
applications to teach me more about the framework.

My question is, how do you best handle multi-part layouts?

For instance, a Layout can be composed of a Body and a Sidebar. The
Sidebar can be a component.

My current approach is to have a

Page.java:

public Page {
  @Component
  private Layout _layout;
  @Component
  private Sidebar _sidebar;
}

Page.html:

<t:layout t:id="layout" blah>
<div id="main">
fee fi fo fum
</div>
<t:sidebar t:id="sidebar" bar="true"/>
</t:layout>

This feels suboptimal, as I'm encoding the location of the sidebar into 
each and every page (namely always coming after the main div). I'd like 
to have the Sidebar component in the Layout component, but feed this 
component from the Page to the Layout (as the Sidebar component could be 
different on every page). I.e., <t:layout sidebar="sidebar">, but that 
is a parameter, not a component, so afaik won't work like I expect it to 
(it didn't in testing, but could have been anything).

Any way of accomplishing this? Any better solutions to this problem? Am 
I missing something?


BTW, T5 is a great framework - having lots of fun with it!

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


Re: T5: Best page templating strategy

Posted by Howard Lewis Ship <hl...@gmail.com>.
This could also be written as:

Block onBeforeRenderBody() { return _sidebar; }

On 4/10/07, Yann Ramin <at...@stackworks.net> wrote:
>
> Just figured out you can return the block in a render stage to get it to
> render. Deceptively simple, but the docs (from my reading), didn't
> mention it.
>
>         @BeforeRenderBody
>         Block doSidebar()
>         {
>                 return _sidebar;
>         }
>
>
> Yann Ramin wrote:
> > I got a good start on this, but still missing something fundamental.
> >
> > In Page.java, I have the Sidebar component.
> > In Page.html, I pass the component in a parameter
> > <t:parameter name="sidebar">
> >     <t:sidebar/>
> > </t:parameter>
> >
> > In Layout.java I have a sidebar block
> >
> > @Parameter(required=true)
> > private Block _sidebar;
> >
> > What I can't figure out is how to get the block to render.
> >
> > Thanks for all of your suggestions so far!
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: T5: Best page templating strategy

Posted by Yann Ramin <at...@stackworks.net>.
Just figured out you can return the block in a render stage to get it to 
render. Deceptively simple, but the docs (from my reading), didn't 
mention it.

	@BeforeRenderBody
	Block doSidebar()
	{
		return _sidebar;
	}


Yann Ramin wrote:
> I got a good start on this, but still missing something fundamental.
> 
> In Page.java, I have the Sidebar component.
> In Page.html, I pass the component in a parameter
> <t:parameter name="sidebar">
>     <t:sidebar/>
> </t:parameter>
> 
> In Layout.java I have a sidebar block
> 
> @Parameter(required=true)
> private Block _sidebar;
> 
> What I can't figure out is how to get the block to render.
> 
> Thanks for all of your suggestions so far!
> 
> 

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


Re: T5: Best page templating strategy

Posted by Yann Ramin <at...@stackworks.net>.
I got a good start on this, but still missing something fundamental.

In Page.java, I have the Sidebar component.
In Page.html, I pass the component in a parameter
<t:parameter name="sidebar">
	<t:sidebar/>
</t:parameter>

In Layout.java I have a sidebar block

@Parameter(required=true)
private Block _sidebar;

What I can't figure out is how to get the block to render.

Thanks for all of your suggestions so far!


Howard Lewis Ship wrote:
> If the sidebar really changes for each page, then it can be a Block
> parameter to the layout component. This will allow the layout
> component to control where, within its templates, the sidebar appears.
> Check out the t:parameter documentation.
> 
> On 4/10/07, Stephane PAQUET <st...@free.fr> wrote:
>> Just one question, why don't  you use a CSS layout + ASSET in stead
>> of component (this does not apply to the sidebar).
>> Rgds,
>>   SP
>>
>> On Apr 10, 2007, at 8:28 AM, Yann Ramin wrote:
>>
>> > I'm using T5 to do some experimental testing, creating some mockup
>> > applications to teach me more about the framework.
>> >
>> > My question is, how do you best handle multi-part layouts?
>> >
>> > For instance, a Layout can be composed of a Body and a Sidebar. The
>> > Sidebar can be a component.
>> >
>> > My current approach is to have a
>> >
>> > Page.java:
>> >
>> > public Page {
>> >  @Component
>> >  private Layout _layout;
>> >  @Component
>> >  private Sidebar _sidebar;
>> > }
>> >
>> > Page.html:
>> >
>> > <t:layout t:id="layout" blah>
>> > <div id="main">
>> > fee fi fo fum
>> > </div>
>> > <t:sidebar t:id="sidebar" bar="true"/>
>> > </t:layout>
>> >
>> > This feels suboptimal, as I'm encoding the location of the sidebar
>> > into each and every page (namely always coming after the main div).
>> > I'd like to have the Sidebar component in the Layout component, but
>> > feed this component from the Page to the Layout (as the Sidebar
>> > component could be different on every page). I.e., <t:layout
>> > sidebar="sidebar">, but that is a parameter, not a component, so
>> > afaik won't work like I expect it to (it didn't in testing, but
>> > could have been anything).
>> >
>> > Any way of accomplishing this? Any better solutions to this
>> > problem? Am I missing something?
>> >
>> >
>> > BTW, T5 is a great framework - having lots of fun with it!
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>>
> 
> 

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


Re: T5: Best page templating strategy

Posted by Howard Lewis Ship <hl...@gmail.com>.
If the sidebar really changes for each page, then it can be a Block
parameter to the layout component. This will allow the layout
component to control where, within its templates, the sidebar appears.
 Check out the t:parameter documentation.

On 4/10/07, Stephane PAQUET <st...@free.fr> wrote:
> Just one question, why don't  you use a CSS layout + ASSET in stead
> of component (this does not apply to the sidebar).
> Rgds,
>   SP
>
> On Apr 10, 2007, at 8:28 AM, Yann Ramin wrote:
>
> > I'm using T5 to do some experimental testing, creating some mockup
> > applications to teach me more about the framework.
> >
> > My question is, how do you best handle multi-part layouts?
> >
> > For instance, a Layout can be composed of a Body and a Sidebar. The
> > Sidebar can be a component.
> >
> > My current approach is to have a
> >
> > Page.java:
> >
> > public Page {
> >  @Component
> >  private Layout _layout;
> >  @Component
> >  private Sidebar _sidebar;
> > }
> >
> > Page.html:
> >
> > <t:layout t:id="layout" blah>
> > <div id="main">
> > fee fi fo fum
> > </div>
> > <t:sidebar t:id="sidebar" bar="true"/>
> > </t:layout>
> >
> > This feels suboptimal, as I'm encoding the location of the sidebar
> > into each and every page (namely always coming after the main div).
> > I'd like to have the Sidebar component in the Layout component, but
> > feed this component from the Page to the Layout (as the Sidebar
> > component could be different on every page). I.e., <t:layout
> > sidebar="sidebar">, but that is a parameter, not a component, so
> > afaik won't work like I expect it to (it didn't in testing, but
> > could have been anything).
> >
> > Any way of accomplishing this? Any better solutions to this
> > problem? Am I missing something?
> >
> >
> > BTW, T5 is a great framework - having lots of fun with it!
> >
> > ---------------------------------------------------------------------
> > 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
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: T5: Best page templating strategy

Posted by Stephane PAQUET <st...@free.fr>.
Just one question, why don't  you use a CSS layout + ASSET in stead  
of component (this does not apply to the sidebar).
Rgds,
  SP

On Apr 10, 2007, at 8:28 AM, Yann Ramin wrote:

> I'm using T5 to do some experimental testing, creating some mockup
> applications to teach me more about the framework.
>
> My question is, how do you best handle multi-part layouts?
>
> For instance, a Layout can be composed of a Body and a Sidebar. The
> Sidebar can be a component.
>
> My current approach is to have a
>
> Page.java:
>
> public Page {
>  @Component
>  private Layout _layout;
>  @Component
>  private Sidebar _sidebar;
> }
>
> Page.html:
>
> <t:layout t:id="layout" blah>
> <div id="main">
> fee fi fo fum
> </div>
> <t:sidebar t:id="sidebar" bar="true"/>
> </t:layout>
>
> This feels suboptimal, as I'm encoding the location of the sidebar  
> into each and every page (namely always coming after the main div).  
> I'd like to have the Sidebar component in the Layout component, but  
> feed this component from the Page to the Layout (as the Sidebar  
> component could be different on every page). I.e., <t:layout  
> sidebar="sidebar">, but that is a parameter, not a component, so  
> afaik won't work like I expect it to (it didn't in testing, but  
> could have been anything).
>
> Any way of accomplishing this? Any better solutions to this  
> problem? Am I missing something?
>
>
> BTW, T5 is a great framework - having lots of fun with it!
>
> ---------------------------------------------------------------------
> 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