Check the Components / Extended Templates proposal. It allows to :
* Define template definition (url+attributes) in a central file (xml)
* Define definition by inheritance
* Use a template definition name as struts-config forward parameter
* And much more ...
Ideas that you propose are in Components, maybe in a slightly different way.
Cedric
Components sites :
http://www.lifl.fr/~dumoulin/components/
(mirror) : http://www.geocities.com/cedricdumoulin/components/
Chris Miller wrote:
> First off, I've been off this mailing list for quite a while, so please
> excuse me if this has already been discussed (how can I search the mailing
> list easily?).
>
> I'm trying to set up a website using Struts' templating functionality,
> however I've run into a 'problem'.
>
> Looking at the Struts template example app, it seems to me that the way the
> templating engine works negates the point of using Struts in the first
> place!
>
> For every page on the site, there is a template JSP page, eg
> introduction.jsp, which contains something like:
>
> <%@ taglib uri='/WEB-INF/struts-template.tld' prefix='template' %>
>
> <template:insert template='/chapterTemplate.jsp'>
> <template:put name='title' content='Templates' direct='true'/>
> <template:put name='header' content='/header.html' />
> <template:put name='sidebar' content='/sidebar.jsp' />
> <template:put name='content' content='/introduction.html'/>
> <template:put name='footer' content='/footer.html' />
> </template:insert>
>
> And in struts-config.xml there's no 'introduction.do' action, rather the
> introduction.jsp page is referenced directly.
>
> Sure it's easy to change the header, sidebar, footer, but by using this
> approach I think we lose a lot of the benefits of Struts. As it stands,
> struts-config.xml no longer holds all of my JSP references, so restructuring
> the site is very difficult. It would be very nice to be able to completely
> eliminate the introduction.jsp page, and instead transfer the header/content
> etc definition into struts-config.xml. Is there a way to do this already
> that I've overlooked?
>
> If not, what I would like to see is the ability to assign parameters in
> struts-config.xml, so we could do something like this:
>
> <global-forwards>
> <forward name="chapterTemplate" path="/chapterTemplate.jsp">
> </global-forwards>
>
> <global-params>
> <param name="header" value="/header.html"/>
> <param name="sidebar" value="/sidebar.jsp"/>
> <param name="footer" value="/footer.html"/>
> </global-params>
>
> <action path="/introduction" type="ChapterTemplateAction">
> <param name="title" value="Introduction"/>
> <param name="content" value="/introduction.html"/>
> </action>
>
> ChapterTemplateAction would perform whatever setup was required, and then
> return the global chapterTemplate forward. chapterTemplate.jsp would be
> similar to the existing page in the template example app.
>
> It may be that we need parameters like I've specified above (which would be
> quite generic and useful for lots of things besides templating I suspect),
> and also say a <template name="content" value="/introduction.html"/> tag to
> handle the templating side of things.
>
> I've glossed over a few details (such as how the parameters get put into
> request scope and passed through to chapterTemplate.jsp), but in principal
> at least, what do people think about this?
>
> Regards,
> Chris Miller