You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Greg Reddin <gr...@apache.org> on 2006/08/30 16:32:39 UTC
[Tiles 2.0] Tiles Without Intermediate Pages WAS: [tiles] page content
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Tiles 2.0] Tiles Without Intermediate Pages WAS: [tiles] page content
Posted by Wendy Smoak <ws...@gmail.com>.
On 8/30/06, Antonio Petrelli <br...@tariffenet.it> wrote:
> P.S.: Should we use [Tiles 2.0] when referring to new Tiles? I asked
> this because the site it is written to use [tiles] instead (anyway
> [Tiles 2.0] is much clearer).
It's just a tag for those who want to filter on the subject line... I
would suggest [tiles2], but the person who changes the page gets to
decide. :) The file is index.xml in
http://svn.apache.org/repos/asf/struts/sandbox/trunk/tiles/src/site/xdoc/
.
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Tiles 2.0] Tiles Without Intermediate Pages WAS: [tiles] page
content
Posted by Antonio Petrelli <br...@tariffenet.it>.
Mehdi Bahribayli ha scritto:
> <%@ taglib uri="http://xplanner.org/xplanner-taglib" prefix="xplanner" %>
>
> <xplanner:content definition="tiles:edit" >
> ...
> <!- you can add 'put' tages -->
> <tiles:put name="editMessage">iteration.editor.edit_prefix</tiles:put>
> ...
> <!-- content goes here! -->
> </xplanner:content>
>
> Take a look at 'conent' tag source code. This can give you some idea.
>
It's better not to do it: it's LGPL and coders minds (me included) will
be tainted, raising possible licensing issues. Anyway the concept is
important.
> PS I still get exception when use 'put' tag in my page (with and without body). 'put' works in definitions but it results in exception in page.
>
Please, if you can, open a JIRA issue for this.
Thank you
Antonio
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Tiles 2.0] Tiles Without Intermediate Pages WAS: [tiles] page content
Posted by Mehdi Bahribayli <ba...@yahoo.com>.
>Greg Reddin ha scritto:
>> <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>
>
>It seems that <tiles:put> already accepts the body so it "potentially"
>could work (though it seems that Mehdi made a test and it doesn't
>work).
>Anyway the "default" part should be implemented.
>It could be something like:
>
><tiles:insert name="myAttribute" type="attribute">
>Default content
></tiles:insert>
>
>Or
>
><tiles:insert name="myAttribute" type="attribute"
>defaultValue="/mydefault.jsp" defaultType="template" />
>
>Antonio
>
>P.S.: Should we use [Tiles 2.0] when referring to new Tiles? I asked
>this because the site it is written to use [tiles] instead (anyway
>[Tiles 2.0] is much clearer).
I have previously seen that some projects use their own costume tags to add this functionality for example xplanner does it this way:
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://xplanner.org/xplanner-taglib" prefix="xplanner" %>
<xplanner:content definition="tiles:edit" >
...
<!- you can add 'put' tages -->
<tiles:put name="editMessage">iteration.editor.edit_prefix</tiles:put>
...
<!-- content goes here! -->
</xplanner:content>
Take a look at 'conent' tag source code. This can give you some idea.
Mehdi
PS I still get exception when use 'put' tag in my page (with and without body). 'put' works in definitions but it results in exception in page.
---------------------------------
All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.
Re: [Tiles 2.0] Tiles Without Intermediate Pages WAS: [tiles] page
content
Posted by Antonio Petrelli <br...@tariffenet.it>.
Greg Reddin ha scritto:
> <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>
It seems that <tiles:put> already accepts the body so it "potentially"
could work (though it seems that Mehdi made a test and it doesn't work).
Anyway the "default" part should be implemented.
It could be something like:
<tiles:insert name="myAttribute" type="attribute">
Default content
</tiles:insert>
Or
<tiles:insert name="myAttribute" type="attribute"
defaultValue="/mydefault.jsp" defaultType="template" />
Antonio
P.S.: Should we use [Tiles 2.0] when referring to new Tiles? I asked
this because the site it is written to use [tiles] instead (anyway
[Tiles 2.0] is much clearer).
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [Tiles 2.0] Tiles Without Intermediate Pages WAS: [tiles] page content
Posted by Mehdi Bahribayli <ba...@yahoo.com>.
Greg Reddin <gr...@apache.org> wrote: 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
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
If you're using Tiles with Struts you can use the forward mechanism
to achieve this without the intermediate JSP page:
But you essentially have to do the intermediate page in tiles-defs.xml:
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:
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:
Default Header Stuff
Default Body Stuff
Default Footer Stuff
Then you extend it with a page like this:
Extended/Overridden Body Content
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Facelets is a good framework for JSF presentation. It follows JSF lifecycle (but JSP does not) but it has shortcommings yet. It is not as mature as JSP (no support for i18n, very restricted set of tags to name a few) but it will not remain so. I think it is a good idea to add "inline Tiles" feature to Tiles for now.
---------------------------------
Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.