You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Schumeyer <rs...@ieee.org> on 2006/10/31 06:43:38 UTC

Tiles "best practices" question

I'm a new tiles user.  I'm using the tiles-defs.xml method for 
definitions (if it matters).

I have a layout that includes: <tiles:insert attribute="body"/>

My definition does *not* include "body"

The "actual" jsp page determines the proper value for "body":

<tiles:insert definition="library.default">
<tiles:put name="body" value="/pages/successBody.jsp"/>
</tiles:insert>

Question: the way I'm doing this means I now have *two *pages for every 
page...in my case the "success.jsp" page that contains the 
<tiles:insert> and also the "successBody.jsp" page containing the actual 
content of the page.

Is this necessary, or is there a better way?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles "best practices" question

Posted by Rick Schumeyer <rs...@ieee.org>.
I have decided to use Antonio's suggestion.  Every page now has an entry 
in tiles-defs.xml.  For example
    <definition name="welcome" extends="default">
        <put name="body" value="/pages/Welcome.jsp" />
    </definition>

Then I just write a Welcome.jsp that only contains the body for the 
welcome page.

So for every page I want to add, I add one jsp file and one entry in 
tiles-defs.xml.

If anyone know a better way, please let me know!  But this method seems 
reasonable.

Adam Hardy wrote:
> Antonio Petrelli on 31/10/06 08:07, wrote:
>> Rick Schumeyer ha scritto:
>>> I have a layout that includes: <tiles:insert attribute="body"/>
>>>
>>> My definition does *not* include "body"
>>>
>>> The "actual" jsp page determines the proper value for "body":
>>>
>>> <tiles:insert definition="library.default">
>>> <tiles:put name="body" value="/pages/successBody.jsp"/>
>>> </tiles:insert>
>>>
>>> Question: the way I'm doing this means I now have *two *pages for 
>>> every page...in my case the "success.jsp" page that contains the 
>>> <tiles:insert> and also the "successBody.jsp" page containing the 
>>> actual content of the page.
>>>
>>> Is this necessary, or is there a better way?
>>
>> Eh, this is a good question. There is another (but not necessarily 
>> better) way: create an extended definition for each page and then 
>> forward directly to the definition in your Struts action. Anyway they 
>> are still 2 objects (a definition and a JSP page) for each final page.
>> Probably a "better" way will be implemented in Tiles 2 (though I 
>> don't know what it will be :-) ).
>
> I never had to use a JSP unnecessarily purely because of tiles. I'm 
> sure if you could explain further, I could give you a solution to 
> avoid superfluous JSPs.
>
> I dont follow the description of your problem though. What do you mean 
> by the 'actual' JSP if it's not your layout? I'm also not familiar 
> with the use of the <tiles:insert definition=""> tag. Don't you mean 
> 'attribute' instead of 'definition' to use a tile def from the 
> tiles-defs.xml?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles "best practices" question

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Antonio Petrelli on 31/10/06 08:07, wrote:
> Rick Schumeyer ha scritto:
>> I have a layout that includes: <tiles:insert attribute="body"/>
>>
>> My definition does *not* include "body"
>>
>> The "actual" jsp page determines the proper value for "body":
>>
>> <tiles:insert definition="library.default">
>> <tiles:put name="body" value="/pages/successBody.jsp"/>
>> </tiles:insert>
>>
>> Question: the way I'm doing this means I now have *two *pages for 
>> every page...in my case the "success.jsp" page that contains the 
>> <tiles:insert> and also the "successBody.jsp" page containing the 
>> actual content of the page.
>>
>> Is this necessary, or is there a better way?
> 
> Eh, this is a good question. There is another (but not necessarily 
> better) way: create an extended definition for each page and then 
> forward directly to the definition in your Struts action. Anyway they 
> are still 2 objects (a definition and a JSP page) for each final page.
> Probably a "better" way will be implemented in Tiles 2 (though I don't 
> know what it will be :-) ).

I never had to use a JSP unnecessarily purely because of tiles. I'm sure if you 
could explain further, I could give you a solution to avoid superfluous JSPs.

I dont follow the description of your problem though. What do you mean by the 
'actual' JSP if it's not your layout? I'm also not familiar with the use of the 
<tiles:insert definition=""> tag. Don't you mean 'attribute' instead of 
'definition' to use a tile def from the tiles-defs.xml?



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles "best practices" question

Posted by Antonio Petrelli <ap...@apache.org>.
Rick Schumeyer ha scritto:
> I have a layout that includes: <tiles:insert attribute="body"/>
>
> My definition does *not* include "body"
>
> The "actual" jsp page determines the proper value for "body":
>
> <tiles:insert definition="library.default">
> <tiles:put name="body" value="/pages/successBody.jsp"/>
> </tiles:insert>
>
> Question: the way I'm doing this means I now have *two *pages for 
> every page...in my case the "success.jsp" page that contains the 
> <tiles:insert> and also the "successBody.jsp" page containing the 
> actual content of the page.
>
> Is this necessary, or is there a better way?

Eh, this is a good question. There is another (but not necessarily 
better) way: create an extended definition for each page and then 
forward directly to the definition in your Struts action. Anyway they 
are still 2 objects (a definition and a JSP page) for each final page.
Probably a "better" way will be implemented in Tiles 2 (though I don't 
know what it will be :-) ).

Ciao
Antonio


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org