You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brady Hegberg <br...@bitstream.net> on 2003/12/27 07:12:26 UTC

tiles, conditional choice of

I've been trying to find the best way to handle a situation where you
have various formats for a tile and the tile appearance is chosen at
run-time.

<definition name="showList" extends="mainLayout">
  <put name="header" value="/header.jsp"/>
  <put name="body" value="/????"/>
  <put name="footer" value="/footer.jsp"/>
</definition>

And I have content1.jsp, content2.jsp and content3.jsp which can be
loaded into the page

Should I:

1.  Have a single tile with choose statements to determine the format.
2.  Have a single master tile which chooses between various tiles and
loads the selected one?  (If possible?)
3.  Have a ClassController or TilesAction class which changes the tile
object and loads the chosen tile into the tile object before displaying
it.  (If so how is this done?  Any examples available?)

I found a couple similar references in the archives but no definitive
answer. 

Thanks,
Brady

PS:  It would be cool if you could create an action for a tile and then
do an actionForward which returns the chosen tile into the correct spot
on the calling page but I don't believe this is possible.  At least I've
never seen anything that indicated it could be done.


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


Re: tiles, conditional choice of

Posted by Brice Ruth <br...@fiskars.com>.
No sweat, Vic :)

.... wrote:

> Brice Ruth wrote:
>
>> One recommendation I've received from this list is to have your 
>> 'variable' tile be an Action, so that you would have an order of 
>> magnitude less tile defs to create ... at least, that's how I 
>> understood it :)
>>
> Sorry about that;-}It's not easy to explain on the list. Now there is 
> tiles EL, so even more tricks are possible. And.. one day the 
> signature for tile action may be same as action, so even more tricks.
>
> .V
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>

-- 
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.


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


Re: tiles, conditional choice of

Posted by "...." <ce...@basebeans.com>.
Brice Ruth wrote:
> One recommendation I've received from this list is to have your 
> 'variable' tile be an Action, so that you would have an order of 
> magnitude less tile defs to create ... at least, that's how I understood 
> it :)
> 
Sorry about that;-}It's not easy to explain on the list. Now there is 
tiles EL, so even more tricks are possible. And.. one day the signature 
for tile action may be same as action, so even more tricks.

.V



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


Re: tiles, conditional choice of

Posted by Brice Ruth <br...@fiskars.com>.
One recommendation I've received from this list is to have your 
'variable' tile be an Action, so that you would have an order of 
magnitude less tile defs to create ... at least, that's how I understood 
it :)

Brady Hegberg wrote:

>Of course!  I just need to forward to the def that corresponds to the
>user's settings.  Very simple and elegant.
>
>However, theoretically, what if I had three tiles in a definition, each
>of which could get any one of the same 10 different values.  In that
>case I'd need to create 1000 definitions in my tile-defs.  Is there a
>simple way around that?
>
>  
>
>>There are a number of options available here, i'd have a different def 
>>that extends showList , I'd call this base.list and then have different 
>>defs per list.
>>
>>name="user.list" extends="base.list"
>>
>>in fact i assumed you'd only have to over load body, you could even 
>>have a def as the value of body.
>>
>>
>>On 27 Dec 2003, at 06:12, Brady Hegberg wrote:
>>
>>    
>>
>>>I've been trying to find the best way to handle a situation where you
>>>have various formats for a tile and the tile appearance is chosen at
>>>run-time.
>>>
>>><definition name="showList" extends="mainLayout">
>>>  <put name="header" value="/header.jsp"/>
>>>  <put name="body" value="/????"/>
>>>  <put name="footer" value="/footer.jsp"/>
>>></definition>
>>>
>>>And I have content1.jsp, content2.jsp and content3.jsp which can be
>>>loaded into the page
>>>
>>>Should I:
>>>
>>>1.  Have a single tile with choose statements to determine the format.
>>>2.  Have a single master tile which chooses between various tiles and
>>>loads the selected one?  (If possible?)
>>>3.  Have a ClassController or TilesAction class which changes the tile
>>>object and loads the chosen tile into the tile object before displaying
>>>it.  (If so how is this done?  Any examples available?)
>>>
>>>I found a couple similar references in the archives but no definitive
>>>answer.
>>>
>>>Thanks,
>>>Brady
>>>
>>>PS:  It would be cool if you could create an action for a tile and then
>>>do an actionForward which returns the chosen tile into the correct spot
>>>on the calling page but I don't believe this is possible.  At least 
>>>I've
>>>never seen anything that indicated it could be done.
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>

-- 
Brice D. Ruth
Sr. IT Analyst
Fiskars Brands, Inc.


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


Re: tiles, conditional choice of

Posted by Mark Lowe <ma...@talk21.com>.
You could over load on the insert

<tiles:insert attribute="example.page">
	<tiles:put name="body" value="<%= body %>" />
</titles:insert>

or do it a specialized action. There are plenty of options although I 
have trouble thinking of many scenarios where having 1000 different 
definitions would be required.

In such a case having an action that mediated in the tile selection i 
guess could be one means of doing what i think you're saying.

In the above case for example you could have your action add a request 
attribute called body or even have an action that extends TileAction 
and mess with whatever you like.

On 27 Dec 2003, at 20:55, Brady Hegberg wrote:

> Of course!  I just need to forward to the def that corresponds to the
> user's settings.  Very simple and elegant.
>
> However, theoretically, what if I had three tiles in a definition, each
> of which could get any one of the same 10 different values.  In that
> case I'd need to create 1000 definitions in my tile-defs.  Is there a
> simple way around that?
>
>> There are a number of options available here, i'd have a different def
>> that extends showList , I'd call this base.list and then have 
>> different
>> defs per list.
>>
>> name="user.list" extends="base.list"
>>
>> in fact i assumed you'd only have to over load body, you could even
>> have a def as the value of body.
>>
>>
>> On 27 Dec 2003, at 06:12, Brady Hegberg wrote:
>>
>>> I've been trying to find the best way to handle a situation where you
>>> have various formats for a tile and the tile appearance is chosen at
>>> run-time.
>>>
>>> <definition name="showList" extends="mainLayout">
>>>   <put name="header" value="/header.jsp"/>
>>>   <put name="body" value="/????"/>
>>>   <put name="footer" value="/footer.jsp"/>
>>> </definition>
>>>
>>> And I have content1.jsp, content2.jsp and content3.jsp which can be
>>> loaded into the page
>>>
>>> Should I:
>>>
>>> 1.  Have a single tile with choose statements to determine the 
>>> format.
>>> 2.  Have a single master tile which chooses between various tiles and
>>> loads the selected one?  (If possible?)
>>> 3.  Have a ClassController or TilesAction class which changes the 
>>> tile
>>> object and loads the chosen tile into the tile object before 
>>> displaying
>>> it.  (If so how is this done?  Any examples available?)
>>>
>>> I found a couple similar references in the archives but no definitive
>>> answer.
>>>
>>> Thanks,
>>> Brady
>>>
>>> PS:  It would be cool if you could create an action for a tile and 
>>> then
>>> do an actionForward which returns the chosen tile into the correct 
>>> spot
>>> on the calling page but I don't believe this is possible.  At least
>>> I've
>>> never seen anything that indicated it could be done.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: tiles, conditional choice of

Posted by Pedro Salgado <sa...@04web.com>.
On 27/12/2003 20:55, "Brady Hegberg" <br...@bitstream.net> wrote:

> Of course!  I just need to forward to the def that corresponds to the
> user's settings.  Very simple and elegant.
> 
> However, theoretically, what if I had three tiles in a definition, each
> of which could get any one of the same 10 different values.  In that
> case I'd need to create 1000 definitions in my tile-defs.  Is there a
> simple way around that?

  Have you tried to use a definition that uses a jsp file that does a
conditional include according to a given parameter?

<definition name="choose.def" extends="base.def">
  <put name="header" value="/header.jsp"/>
   <put name="body" value="/choose.jsp"/>  <-----
   <put name="footer" value="/footer.jsp"/>
</definition>

----> choose.jsp

<c:import url='/WEB-INF/com/website/tiles/choose/${request.choose}'/>

Pedro Salgado

> 
>> There are a number of options available here, i'd have a different def
>> that extends showList , I'd call this base.list and then have different
>> defs per list.
>> 
>> name="user.list" extends="base.list"
>> 
>> in fact i assumed you'd only have to over load body, you could even
>> have a def as the value of body.
>> 
>> 
>> On 27 Dec 2003, at 06:12, Brady Hegberg wrote:
>> 
>>> I've been trying to find the best way to handle a situation where you
>>> have various formats for a tile and the tile appearance is chosen at
>>> run-time.
>>> 
>>> <definition name="showList" extends="mainLayout">
>>>   <put name="header" value="/header.jsp"/>
>>>   <put name="body" value="/????"/>
>>>   <put name="footer" value="/footer.jsp"/>
>>> </definition>
>>> 
>>> And I have content1.jsp, content2.jsp and content3.jsp which can be
>>> loaded into the page
>>> 
>>> Should I:
>>> 
>>> 1.  Have a single tile with choose statements to determine the format.
>>> 2.  Have a single master tile which chooses between various tiles and
>>> loads the selected one?  (If possible?)
>>> 3.  Have a ClassController or TilesAction class which changes the tile
>>> object and loads the chosen tile into the tile object before displaying
>>> it.  (If so how is this done?  Any examples available?)
>>> 
>>> I found a couple similar references in the archives but no definitive
>>> answer.
>>> 
>>> Thanks,
>>> Brady
>>> 
>>> PS:  It would be cool if you could create an action for a tile and then
>>> do an actionForward which returns the chosen tile into the correct spot
>>> on the calling page but I don't believe this is possible.  At least
>>> I've
>>> never seen anything that indicated it could be done.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Re: tiles, conditional choice of

Posted by Brady Hegberg <br...@bitstream.net>.
Of course!  I just need to forward to the def that corresponds to the
user's settings.  Very simple and elegant.

However, theoretically, what if I had three tiles in a definition, each
of which could get any one of the same 10 different values.  In that
case I'd need to create 1000 definitions in my tile-defs.  Is there a
simple way around that?

> There are a number of options available here, i'd have a different def 
> that extends showList , I'd call this base.list and then have different 
> defs per list.
> 
> name="user.list" extends="base.list"
> 
> in fact i assumed you'd only have to over load body, you could even 
> have a def as the value of body.
> 
> 
> On 27 Dec 2003, at 06:12, Brady Hegberg wrote:
> 
> > I've been trying to find the best way to handle a situation where you
> > have various formats for a tile and the tile appearance is chosen at
> > run-time.
> >
> > <definition name="showList" extends="mainLayout">
> >   <put name="header" value="/header.jsp"/>
> >   <put name="body" value="/????"/>
> >   <put name="footer" value="/footer.jsp"/>
> > </definition>
> >
> > And I have content1.jsp, content2.jsp and content3.jsp which can be
> > loaded into the page
> >
> > Should I:
> >
> > 1.  Have a single tile with choose statements to determine the format.
> > 2.  Have a single master tile which chooses between various tiles and
> > loads the selected one?  (If possible?)
> > 3.  Have a ClassController or TilesAction class which changes the tile
> > object and loads the chosen tile into the tile object before displaying
> > it.  (If so how is this done?  Any examples available?)
> >
> > I found a couple similar references in the archives but no definitive
> > answer.
> >
> > Thanks,
> > Brady
> >
> > PS:  It would be cool if you could create an action for a tile and then
> > do an actionForward which returns the chosen tile into the correct spot
> > on the calling page but I don't believe this is possible.  At least 
> > I've
> > never seen anything that indicated it could be done.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


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


Re: tiles, conditional choice of

Posted by Mark Lowe <ma...@talk21.com>.
There are a number of options available here, i'd have a different def 
that extends showList , I'd call this base.list and then have different 
defs per list.

name="user.list" extends="base.list"

in fact i assumed you'd only have to over load body, you could even 
have a def as the value of body.


On 27 Dec 2003, at 06:12, Brady Hegberg wrote:

> I've been trying to find the best way to handle a situation where you
> have various formats for a tile and the tile appearance is chosen at
> run-time.
>
> <definition name="showList" extends="mainLayout">
>   <put name="header" value="/header.jsp"/>
>   <put name="body" value="/????"/>
>   <put name="footer" value="/footer.jsp"/>
> </definition>
>
> And I have content1.jsp, content2.jsp and content3.jsp which can be
> loaded into the page
>
> Should I:
>
> 1.  Have a single tile with choose statements to determine the format.
> 2.  Have a single master tile which chooses between various tiles and
> loads the selected one?  (If possible?)
> 3.  Have a ClassController or TilesAction class which changes the tile
> object and loads the chosen tile into the tile object before displaying
> it.  (If so how is this done?  Any examples available?)
>
> I found a couple similar references in the archives but no definitive
> answer.
>
> Thanks,
> Brady
>
> PS:  It would be cool if you could create an action for a tile and then
> do an actionForward which returns the chosen tile into the correct spot
> on the calling page but I don't believe this is possible.  At least 
> I've
> never seen anything that indicated it could be done.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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