One thing that has often bothered me about Tiles in a standalone web
application is the need for a JSP page that "calls" a tiles
definition. Consider the following from the Tiles 2.0 test application:
tiles-defs.xml
<definition name="doc.mainLayout" path="/layout/classicLayout.jsp">
<put name="title" value="Tiles Library Documentation" />
<put name="header" value="/common/header.jsp" />
<put name="menu" value="doc.menu.main" />
<put name="footer" value="/common/footer.jsp" />
<put name="body" value="doc.portal.body" />
</definition>
In this case you have a tile called "doc.mainLayout". In most cases
you want to have a URL that pulls in the doc.mainLayout and replaces
the "body" component with something else. Right now you have to
create an intermediate JSP page:
intermediate.jsp
<tiles:insert name="doc.mainLayout">
<tiles:put name="body" value="/somenewpage.jsp"/>
</tiles:insert>
If you're using Tiles with Struts you can use the forward mechanism
to achieve this without the intermediate JSP page:
<action path="/mypage" forward="doc.myPage">
But you essentially have to do the intermediate page in tiles-defs.xml:
<definition name="doc.myPage" extends="doc.mainLayout">
<put name="body" value="/somenewpage.jsp"/>
</definition>
In JSF you have a similar issue. I haven't used Tiles with JSF yet,
but I think you could do the same thing you do with Struts. You just
use navigation-rules instead of action mappings. I'm currently
building an app using JSF and Facelets. Facelets gets around the
"intermediate" page by being sort of a "backwards" Tiles - or more
precisely - an "inline" Tiles. In Facelets you extend things
inline. Here's an example:
With Tiles you might have a template that does this:
<template-stuff/>
<tiles:insert name="header"/>
<more-template-stuff/>
<tiles:insert name="body"/>
<still-more-template-stuff/>
<tiles:insert name="footer"/>
In the above code your template invokes named "sections" that are
defined in the tile definition. You invoke the template and
substitute values for the named section.
To do the same thing in Facelets you might have this:
<template-stuff/>
<ui:insert name="header">Default Header Stuff</ui:insert>
<more-template-stuff/>
<ui:insert name="body">Default Body Stuff</ui:insert>
<still-more-template-stuff/>
<ui:insert name="footer">Default Footer Stuff</ui:insert>
Then you extend it with a page like this:
<ui:composition template="/layout.xhtml">
<ui:define name="body">
Extended/Overridden Body Content
</ui:define>
</ui:composition>
JSF removes the intermediate step b/c the FacesServlet will always
render a view - so if you hit the URL myapp/somepage.jsf you'll get
forwarded to /somepage.xhtml which can invoke a template. So you can
see how Facelets sort of works backwards. You define a page that
extends a template and defines the extended portions inline. If
Facelets was supported in a standalone environment (i.e. without
JSF) you could possibly just invoke a *.xhtml URL and skip the
intermediate step altogether.
It would be nice if we could make Tiles work this way. Then you'd
have a Facelets-like templating technology that is based on JSP and
works the same in JSF, Struts, any other MVC framework in which it is
supported, and standalone without any MVC framework whatsoever.
Thoughts?
Greg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]