You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Corbin <dc...@imperitek.com> on 2001/09/09 01:16:23 UTC

on templates

I'm building web site that is like many other sites.  It's got a common look
and feel through out the whole system.  At this point, that means that all
the "list a foo" pages share the same basic structure, and all the "foo
form" pages share the same basic structure.  Now, being an experienced
programmer, I *hate* have duplicated code in multilple source files, so I'm
working to prevent duplication in my JSP files so that

First, I took a look at the Struts Template taglib.  Frankly, something
doesn't register in it for me.  It seems overly convuluted, and I have yet
to wrap my head about it.  Maybe I'm just being dense.

After giving it some though, I decided that what I really wanted to do was
much like C pre-processing - includes, and defines.  You define a few macros
(beans).  You include a file.  Should work great.  It did work great for my
"lists of foo" pages.  It failed when I when to do "foo form" pages.  Why?
because, using jsp:include can't handle the case where <html:form> is in one
include, and </html:form> is in a different include.  jsp:include is more
like "call", than include.  So, I switched to <%@ include %>.  Well, that's
worked so far, but I think it will collapse soon, because you can't really
do <bean:write> just ANYWHERE like a real macro, and it's a real pain
because the app server doesn't understand when included files change.

So, I'm here looking for help.  Are there other, better solutions?  If so,
what? Should I spend more time trying to penetrate struts templates?

Thanks very much.
David Corbin


Re: on templates

Posted by Ted Husted <hu...@apache.org>.
Take a good look at the Tiles library, which is the successor to the
template library in 1.0. 

http://www.lifl.fr/~dumoulin/tiles/

(also in the nightly build "contrib" folder)

Start with "Chapter 6 - Definitions" to see where you will be able to go
with this, and then work through the tutorial from the beginning. I'm
working on a rewrite that uses Struts throughout (Tiles works well with
Struts, but is not dependant on Struts), but you will get the idea. 

If you would like to continue your search of another JSP templating
library, general JSP sites are a good resource. Struts should work with
anything.

http://husted.com/about/struts/links.htm#jsp

Another idea would be to look at the Dreamweaver extensions

http://jakarta.apache.org/taglibs/doc/ultradev4-doc/intro.html

and then use the Dreamweaver templating system.


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/


David Corbin wrote:
> 
> I'm building web site that is like many other sites.  It's got a common look
> and feel through out the whole system.  At this point, that means that all
> the "list a foo" pages share the same basic structure, and all the "foo
> form" pages share the same basic structure.  Now, being an experienced
> programmer, I *hate* have duplicated code in multilple source files, so I'm
> working to prevent duplication in my JSP files so that
> 
> First, I took a look at the Struts Template taglib.  Frankly, something
> doesn't register in it for me.  It seems overly convuluted, and I have yet
> to wrap my head about it.  Maybe I'm just being dense.
> 
> After giving it some though, I decided that what I really wanted to do was
> much like C pre-processing - includes, and defines.  You define a few macros
> (beans).  You include a file.  Should work great.  It did work great for my
> "lists of foo" pages.  It failed when I when to do "foo form" pages.  Why?
> because, using jsp:include can't handle the case where <html:form> is in one
> include, and </html:form> is in a different include.  jsp:include is more
> like "call", than include.  So, I switched to <%@ include %>.  Well, that's
> worked so far, but I think it will collapse soon, because you can't really
> do <bean:write> just ANYWHERE like a real macro, and it's a real pain
> because the app server doesn't understand when included files change.
> 
> So, I'm here looking for help.  Are there other, better solutions?  If so,
> what? Should I spend more time trying to penetrate struts templates?
> 
> Thanks very much.
> David Corbin