You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alex Paransky <ap...@standardset.com> on 2002/04/03 18:18:53 UTC

How to avoid a separate .jsp page for body definition when using Templates?

I am currently using Templates (not Tiles) to layout our pages.  While
general components such as menu, header, footer are well defined, same for
all pages, and are included from a global single location, the body is
always different.  So, for every page, we wind up with 2 pages.

page.jsp - uses the <template tags to define the layout
pageContent.jsp - used from page.jsp to define the body content

This is quite cumbersome.  Is there a way to put the layout definition and
the "contents" of at least the body into the same page?  Other things such
as the title, and help text change on a page  by page basis, so it would be
nice to package these two items in to the same page as well.

Is this easier done with Tiles?

Thanks.

-AP_
http://www.alexparansky.com
Java/J2EE Architect/Consultant
http://www.myprofiles.com/member/view.do?profileId=127


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to avoid a separate .jsp page for body definition when usingTemplates?

Posted by Ted Husted <hu...@apache.org>.
Yes, it is easier done with Tiles. 

I believe there is also a technique that you can use with the Template
library to get it to nest the gets and eliminate some extra pages, but
you really are better off with Tiles. 

An important feature is that you can subclass, or extend, Tiles based on
other tiles. In the end, it all begins to resemble actual OOP, and makes
adding and maintaining pages much easier. You can also define tiles
through an XML configuration file, and reference the Tiles definitions
as ActionForwards. 

  <definition name=".Alert" path="/tiles/layouts/Alert.jsp">
      <put name="base"     value="/tiles/Base.jsp" />
      <put name="header"   value="/tiles/FormHeader.jsp" />
      <put name="messages" value="/tiles/Messages.jsp" />
      <put name="footer"   value="/tiles/Footer.html" />
      <!-- extend with title, content -->
  </definition>

  <definition name=".item.Preview" extends=".Alert">
      <put name="title"    value="Preview Item" />
      <put name="content"  value="/pages/item/Preview.jsp" />
  </definition>


 <action 
...
 <forward 
  name="success"  
   path=".item.Preview"/> 
 </action>


-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Alex Paransky wrote:
> 
> I am currently using Templates (not Tiles) to layout our pages.  While
> general components such as menu, header, footer are well defined, same for
> all pages, and are included from a global single location, the body is
> always different.  So, for every page, we wind up with 2 pages.
> 
> page.jsp - uses the <template tags to define the layout
> pageContent.jsp - used from page.jsp to define the body content
> 
> This is quite cumbersome.  Is there a way to put the layout definition and
> the "contents" of at least the body into the same page?  Other things such
> as the title, and help text change on a page  by page basis, so it would be
> nice to package these two items in to the same page as well.
> 
> Is this easier done with Tiles?
> 
> Thanks.
> 
> -AP_
> http://www.alexparansky.com
> Java/J2EE Architect/Consultant
> http://www.myprofiles.com/member/view.do?profileId=127
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>