tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas LE BAS <nle...@bigfoot.com>
Subject Re: MyFaces and Tiles
Date Tue, 18 Sep 2007 18:40:20 GMT
Chris Pratt a écrit :
> On 9/6/07, Chris Pratt <thechrispratt@gmail.com> wrote:
>   
>> On 9/6/07, Ray Clough <rcclough@kamakuraco.com> wrote:
>>     
>>> Are you remembering to set flush=false, and include everything in a
>>> subview, which we do like this in our 'template.jspx" file:
>>>
>>> <f:subview id="menu">
>>>         <tiles:insertAttribute name="menu" flush="false" />
>>>  </f:subview>
>>>
>>> - Ray Clough
>>>
>>>
>>>
>>>       
>> Yup, the layout.jsp is basically:
>>
>> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
>> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>> <f:view>
>>   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
>>     <head>
>>       <title><tiles:insertAttribute name="title"/></title>
>>     </head>
>>     <body>
>>       <tiles:insertAttribute name="body" flush="false" ignore="true"/>
>>     </body>
>>   </html>
>> </f:view>
>>
>> And I'm not creating a sub-view since the included body is a simple <p> tag.
>>
>> But I'm not sure you've seen my latest post, It seemed to have
>> something to do with the relative reference generated in the
>> dispatchToTile method in the ViewHandler.  Thanks for all your help.
>>   (*Chris*)
>>
>>     
> Well, it looks like going forward there are still problems to solve.
> My tiles definition looks like this:
>
>   <definition name="index" template="/layout/layout.jsf">
>     <put-attribute name="title" value="Crash Test Dummy" type="string"/>
>     <put-attribute name="body" value="/body/body.jsp" type="template"/>
>   </definition>
>
> /layout/layout.jsp contains the main <f:view> that encompasses all the
> tiles inserts.
>
> /body/body.jsp contains an <f:subview> and a <h:form> containing a few
> controls.  But when the form gets generated it has the wrong action!
> The generated form comes out like:
>
> <form id="body:_idJsp0" name="body:_idJsp0" method="post"
> action="/crash/layout/layout.jsf"
> enctype="application/x-www-form-urlencoded">
>
> Notice that the action is getting set to the name of the main layout
> template, not back to something that JSF can properly route.
>
> Has anyone been able to get Tiles and JSF working together properly?
> Any help would be massively appreciated.
>   (*Chris*)
>
>   
I do. But then I've a very basic use for tiles (a single definition used
with TilesDecorationFilter).

Here's a piece of advice : Tiles is basically a view technology ("view"
as in MVC2). Thus you should not call FacesServlet (i.e. a *.jsf) from a
tiles definition. You should always use its "*.jsp" counterpart there.
When you call FacesServlet like in "foo.jsf", the request will be
internally forwarded to "foo.jsp", and this is when you want Tiles to
take control.

It is easy enough with the TilesDecorationFilter (I have it working,
even if don't have an example with me at this very moment), and I think
you can do it also with the TilesDispatchServlet by setting
"javax.faces.DEFAULT_SUFFIX" appropriately in web.xml (but I've not
tried it this way... the Filter is just what I need ;) )

Hope this helps
Nick


Mime
View raw message