You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ki Alam <ki...@gmail.com> on 2007/04/18 23:32:36 UTC

T5: html templates & "fragments"

I'm beginning to work with Tapestry 5 and I'd ideally like to have one page
design (created by Dreamweaver) shared between all my pages.  Let's call
that SiteDesignTemplate.html.  This would have <div>s or eve <td>s  into
which I'd like to insert my Start.html and other Tapestry pages as required
for each step in my application.  I've looked at the component code in the
tapestry 5.0.3 source, but I'm having trouble determining the control flow.

Are there any examples of this available for tapestry 5?

Thanks,
Ki

Re: T5: html templates & "fragments"

Posted by Josh Long <st...@gmail.com>.
Ki,

I think you're kind of missing it. It's sort of inverted relative to, say,
Tiles. Frankly, Tapestry's more natural :-)

You create your individual pages "UserHome.html", "Preferences.html", etc.

You also create a "border" or "layout" component that can wrap it's body. In
the way that a div tag "wraps" its contents, you can create a component that
wraps its contents. Thus, any headrs or footers or navigation would be
created once, in this "border" component. The border component needs to only
tell the system where to insert any content that it wraps.   "<t:body/>"
(inside of your border component) tells the system to take whatever is
inside this component on the page it's being used on and insert it here.

Thus, as mentioned before:

Assume youve got a order component with a navigation bar at the top, a
<t:body/> tag in the middle, and a legal notice on the bottom. Writing:

<t:SiteDesignTemplate>
content unique to UserHome.html goes here
</t:SiteDesignTemplate>

would yeild

1. navigation bar
2  "content unique to UserHome.html goes here"
3. legal notice

You need only change your border component once and everything will update
accordingly.

Thanks,

Josh Long
Sun Certified Java Programmer
http://www.joshlong.com

On 4/20/07, Ki Alam <ki...@gmail.com> wrote:
>
> Thanks Howard, I really appreciate taking the time to answer my beginner
> question.
>
> I have a followup question that maybe you could answer for me:
>
> If I use the layout mechanism you've described, and I have 10 Pages (Start
> -> UserHome -> Preferences -> ad naseum), will I be forced to have an HTML
> file for each of those pages that loads a different ComponentTemplate?  Or
> can I associate one HTML with different Components based on the Start.java/
> UserHome.java class?  I'm worried that if I want to make a change to my
> site
> design, I'll then have to make the changes to 10 HTML files.   I feel like
> I
> must be missing something, so if you could point me in the right
> direction,
> that'd be great!
>
> Ki
>
>
> On 4/18/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> >
> > It's a class of component we call a "layout" or a "border".  I.e.
> >
> > <t:layout>
> > My page specific content
> > </t:layout>
> >
> >
> > An the Layout component's template:
> >
> > <html>
> > <head>
> >   ...
> >
> >   <t:body/>  <!-- The page specific content -->
> >
> > ...
> > </body>
> > </html>
> > On 4/18/07, Ki Alam <ki...@gmail.com> wrote:
> > >
> > > I'm beginning to work with Tapestry 5 and I'd ideally like to have one
> > > page
> > > design (created by Dreamweaver) shared between all my pages.  Let's
> call
> > > that SiteDesignTemplate.html.  This would have <div>s or eve
> <td>s  into
> > > which I'd like to insert my Start.html and other Tapestry pages as
> > > required
> > > for each step in my application.  I've looked at the component code in
> > the
> > > tapestry 5.0.3 source, but I'm having trouble determining the control
> > > flow.
> > >
> > > Are there any examples of this available for tapestry 5?
> > >
> > > Thanks,
> > > Ki
> > >
> >
> >
> >
> > --
> > 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
> >
>



-- 
Joshua Long
Sun Certified Java Programmer
http://www.joshlong.com/

Re: T5: html templates & "fragments"

Posted by Ki Alam <ki...@gmail.com>.
Thanks Howard, I really appreciate taking the time to answer my beginner
question.

I have a followup question that maybe you could answer for me:

If I use the layout mechanism you've described, and I have 10 Pages (Start
-> UserHome -> Preferences -> ad naseum), will I be forced to have an HTML
file for each of those pages that loads a different ComponentTemplate?  Or
can I associate one HTML with different Components based on the Start.java /
UserHome.java class?  I'm worried that if I want to make a change to my site
design, I'll then have to make the changes to 10 HTML files.   I feel like I
must be missing something, so if you could point me in the right direction,
that'd be great!

Ki


On 4/18/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> It's a class of component we call a "layout" or a "border".  I.e.
>
> <t:layout>
> My page specific content
> </t:layout>
>
>
> An the Layout component's template:
>
> <html>
> <head>
>   ...
>
>   <t:body/>  <!-- The page specific content -->
>
> ...
> </body>
> </html>
> On 4/18/07, Ki Alam <ki...@gmail.com> wrote:
> >
> > I'm beginning to work with Tapestry 5 and I'd ideally like to have one
> > page
> > design (created by Dreamweaver) shared between all my pages.  Let's call
> > that SiteDesignTemplate.html.  This would have <div>s or eve <td>s  into
> > which I'd like to insert my Start.html and other Tapestry pages as
> > required
> > for each step in my application.  I've looked at the component code in
> the
> > tapestry 5.0.3 source, but I'm having trouble determining the control
> > flow.
> >
> > Are there any examples of this available for tapestry 5?
> >
> > Thanks,
> > Ki
> >
>
>
>
> --
> 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
>

Re: T5: html templates & "fragments"

Posted by Howard Lewis Ship <hl...@gmail.com>.
It's a class of component we call a "layout" or a "border".  I.e.

<t:layout>
  My page specific content
</t:layout>


An the Layout component's template:

<html>
  <head>
   ...

   <t:body/>  <!-- The page specific content -->

  ...
 </body>
</html>
On 4/18/07, Ki Alam <ki...@gmail.com> wrote:
>
> I'm beginning to work with Tapestry 5 and I'd ideally like to have one
> page
> design (created by Dreamweaver) shared between all my pages.  Let's call
> that SiteDesignTemplate.html.  This would have <div>s or eve <td>s  into
> which I'd like to insert my Start.html and other Tapestry pages as
> required
> for each step in my application.  I've looked at the component code in the
> tapestry 5.0.3 source, but I'm having trouble determining the control
> flow.
>
> Are there any examples of this available for tapestry 5?
>
> Thanks,
> Ki
>



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

Re: T5: html templates & "fragments"

Posted by Robert Zeigler <ro...@scazdl.org>.
Hi Ki,

The pattern used in tapestry is to create a "layout" type of  
component, and include that in all of your pages.
So instead of thinking of things as a single page with a set of  
content that goes in the middle, you think of the layout as a  
component which is included in all of your pages.  So  
SiteDesignTemplate.html would be a component template, and you could  
then do:

<t:SiteDesignTemplate ...>
   <!-- page content goes here -->
</t:SiteDesignTemplate>

On your pages.

Robert

On Apr 18, 2007, at 4/184:32 PM , Ki Alam wrote:

> I'm beginning to work with Tapestry 5 and I'd ideally like to have  
> one page
> design (created by Dreamweaver) shared between all my pages.  Let's  
> call
> that SiteDesignTemplate.html.  This would have <div>s or eve <td>s   
> into
> which I'd like to insert my Start.html and other Tapestry pages as  
> required
> for each step in my application.  I've looked at the component code  
> in the
> tapestry 5.0.3 source, but I'm having trouble determining the  
> control flow.
>
> Are there any examples of this available for tapestry 5?
>
> Thanks,
> Ki


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