You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Trevor Porter <tr...@woz.com> on 2003/06/19 01:26:26 UTC

possible to parameterize template path in tiles definition when using tile def config file?

I'm trying to figure out if it's at all possible to parameterize the 
template path for a tiles defintion dynamically at runtime while at the 
same time declaring the tile definitions from a config file. I 
understand that this is straightforward when declaring a tile definition 
within a JSP (<tiles:definition id="definitionName" page="<%layout%>">), 
but I want to use my tile definitions as ActionForwards, thus I need to 
declare them in a config file. This would be useful for scenarios where 
pages need to be laid out differently based on some key (such as user 
preference or browser type) but the struts-config file only knows of a 
single definition to forward to for a given action. For example, imagine 
the following struts-config action mapping:

   <action path="/login"
           type="LoginAction"
           input="/index.jsp"
           name="loginForm"
           validate="true"
           scope="request">            >
     <forward name="success" path=".account.home"/>  
The forward path points to a tiles definition that renders the account 
home page. I would like to dynamically control which template layout 
page is used for this definition from within the LoginAction. Is this 
possible?


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


Re: possible to parameterize template path in tiles definition when using tile def config file?

Posted by Trevor Porter <tr...@woz.com>.
Thanks. I eventually stumbled across the Tile Advanced Features document 
and am now doing just that -- using a Struts action in my tiles 
definition path to dynamically select my layout. Works perfectly for my 
needs.

...Trevor

Cedric Dumoulin wrote:

>
>  The current implementation of Tiles doesn't allow to change 
> dynamically the path/layout of a definition. This is an enhancement 
> request.
>  A workaround is to have a struts action forwarding to different 
> definitions, according to the path you want to use.
>  Another trick is to have a jsp/tiles used as indirection. This tile 
> is used as the path of your definition. This tile do an insert with 
> the path set from one of the attribute (as you suggested), and pass 
> all others attribute.
>
>
>  Hope this help,
>
>    Cedric
>
> Trevor Porter wrote:
>
>> I'm trying to figure out if it's at all possible to parameterize the 
>> template path for a tiles defintion dynamically at runtime while at 
>> the same time declaring the tile definitions from a config file. I 
>> understand that this is straightforward when declaring a tile 
>> definition within a JSP (<tiles:definition id="definitionName" 
>> page="<%layout%>">), but I want to use my tile definitions as 
>> ActionForwards, thus I need to declare them in a config file. This 
>> would be useful for scenarios where pages need to be laid out 
>> differently based on some key (such as user preference or browser 
>> type) but the struts-config file only knows of a single definition to 
>> forward to for a given action. For example, imagine the following 
>> struts-config action mapping:
>>
>>   <action path="/login"
>>           type="LoginAction"
>>           input="/index.jsp"
>>           name="loginForm"
>>           validate="true"
>>           scope="request">            >
>>     <forward name="success" path=".account.home"/>  The forward path 
>> points to a tiles definition that renders the account home page. I 
>> would like to dynamically control which template layout page is used 
>> for this definition from within the LoginAction. Is this possible?
>>
>>
>> ---------------------------------------------------------------------
>> 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: possible to parameterize template path in tiles definition when using tile def config file?

Posted by Cedric Dumoulin <ce...@lifl.fr>.
  The current implementation of Tiles doesn't allow to change 
dynamically the path/layout of a definition. This is an enhancement request.
  A workaround is to have a struts action forwarding to different 
definitions, according to the path you want to use.
  Another trick is to have a jsp/tiles used as indirection. This tile is 
used as the path of your definition. This tile do an insert with the 
path set from one of the attribute (as you suggested), and pass all 
others attribute.
 
 
  Hope this help,

    Cedric

Trevor Porter wrote:

> I'm trying to figure out if it's at all possible to parameterize the 
> template path for a tiles defintion dynamically at runtime while at 
> the same time declaring the tile definitions from a config file. I 
> understand that this is straightforward when declaring a tile 
> definition within a JSP (<tiles:definition id="definitionName" 
> page="<%layout%>">), but I want to use my tile definitions as 
> ActionForwards, thus I need to declare them in a config file. This 
> would be useful for scenarios where pages need to be laid out 
> differently based on some key (such as user preference or browser 
> type) but the struts-config file only knows of a single definition to 
> forward to for a given action. For example, imagine the following 
> struts-config action mapping:
>
>   <action path="/login"
>           type="LoginAction"
>           input="/index.jsp"
>           name="loginForm"
>           validate="true"
>           scope="request">            >
>     <forward name="success" path=".account.home"/>  The forward path 
> points to a tiles definition that renders the account home page. I 
> would like to dynamically control which template layout page is used 
> for this definition from within the LoginAction. Is this possible?
>
>
> ---------------------------------------------------------------------
> 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