tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacek Wo┼║niczak <jwoznic...@gmail.com>
Subject Re: Tiles 2.1 with JSF 1.2 - definition update
Date Tue, 06 Jan 2009 08:15:18 GMT
Hi Nicolas,
big thanks for your response. It explained me a lot.


Nicolas LE BAS pisze:
> I'm not sure what you mean by "changing" a tiles definition.
Changing its attributes, adding, deleting.

> Basically a tiles definition is a singleton object, shared by all 
> threads in the server, like a Servlet. Modifying this objet in an 
> ActionListener, i.e. for the purpose of fulfilling a single request, 
> doesn't sound safe. 
Yep, i didn't know this. I thought that Tiles stores a copy of 
definition for a single, particular request.

> But why should you want to do this on a per-request basis? I cannot 
> think of any use case right now...
I'll explain what I was testing when I downloaded Tiles

layout page (I will omit taglib imports etc.)

            <meta http-equiv="Content-Type" content="text/html; 
            <title>JSP Page</title>
            <tiles:insertAttribute name="part1" />

simple tile with action

<h1><h:outputText value="hello" /></h1>
    <h:commandLink action="#{MyBean.doWork}">Do Work</h:commandLink>

Tiles definition:

     <definition name="def" template="/layout.jsp">
        <put-attribute name="part1" value="/part.jsp" />

and one and only one page:

<tiles:insertDefinition name="def">
    <tiles:putAttribute name="part1" value="/tile.jsp"/>
and for example in MyBean method doWork i don't want to return any 
outcome and display new page but simply modify (for example add a new 
attribute) definition "def" and then redisplay the page start.jsp.

> Additionally, adopting a more philosophical point of view, I believe 
> your MVC2 controller should not be aware of the structure of its view. 
> You should not have to modify the backing bean if you decide to render 
> the view using Plain Old JSP or Facelets instead of Tiles, or if you 
> want to redesign your Tiles Definition (put the menu on the top of the 
> page, when it was on the left).
That's true. I'm new in all this jsf and mvc concepts, so I was a little 
I don't want to use Facelets - Tiles are more clear for me.

> Therefore I believe that referencing Tiles in an ActionListener or 
> Backing Bean is not a good programming practice. It would be better to 
> reference a request attribute (or even better: a Backing Bean 
> property) both in the ActionListener and the Tiles Definition.
> It would keep both technologies unaware of each other, and I believe 
> things would evolve more smoothly afterwards.
> What do you think ?
This is the best solution and this is a way I'll go.

Thanks a lot for your hints!


View raw message