You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Ludwig <ge...@gmail.com> on 2013/05/07 19:12:52 UTC

How to dynamically specify the template for the Dynamic component?

I'm trying to use the Dynamic component so I can specify the tml at runtime.

These work:

<t:dynamic template="myTemplate.tml" ...

<t:dynamic template="asset:myTemplate.tml" ...


But I need to read the template name from a property. Unfortunately, these
do not work:

<t:dynamic template="templateName" ... (where templateName is a String
property)

<t:dynamic template="${templateName}" ... (where templateName is a String
property)

<t:dynamic template="prop:templateName" ... (where templateName is a String
property)

<t:dynamic template="asset:templateName}" ... (where templateName is a
String property)

<t:dynamic template="asset:${templateName}" ... (where templateName is a
String property)


Any hints on how to make this work?

Re: How to dynamically specify the template for the Dynamic component?

Posted by George Ludwig <ge...@gmail.com>.
Thanks Thiago, I'll try that. I did first look at the Tapestry docs, and
saw that the template parameter was of type org.apache.tapestry5.services.
dynamic.DynamicTemplate and I had not idea what to do what that.


On Tue, May 7, 2013 at 11:22 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Tue, 07 May 2013 14:12:52 -0300, George Ludwig <ge...@gmail.com>
> wrote:
>
>  I'm trying to use the Dynamic component so I can specify the tml at
>> runtime.
>>
>
> Notice the template parameter is of type Asset, so that's what you should
> pass to it. The default binding is 'asset', and I guess you overlooked this
> important fact. Use the AssetSource service instead. Something like this:
>
> @Inject
> private AssetSource assetSource;
>
> public Asset getTemplate() {
>         // use AssertSource to get the Asset
> }
>
> <t:dynamic template="prop:template"/>
>
>
>  These work:
>>
>> <t:dynamic template="myTemplate.tml" ...
>>
>> <t:dynamic template="asset:myTemplate.**tml" ...
>>
>>
>> But I need to read the template name from a property. Unfortunately, these
>> do not work:
>>
>> <t:dynamic template="templateName" ... (where templateName is a String
>> property)
>>
>
> It won't work because the default binding of the parameter is Asset.
>
>
>  <t:dynamic template="${templateName}" ... (where templateName is a String
>> property)
>>
>
> Never, never, never ever use expansions when passing component parameter
> values.
>
>
>  <t:dynamic template="prop:templateName" ... (where templateName is a
>> String property)
>>
>
> It won't work because the default binding of the parameter is Asset.
>
>
>  <t:dynamic template="asset:templateName}" ... (where templateName is a
>> String property)
>>
>
> The asset binding doesn't support properties.
>
>
>  <t:dynamic template="asset:${**templateName}" ... (where templateName is
>> a
>> String property)
>>
>
> The asset binding doesn't support ${}
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: How to dynamically specify the template for the Dynamic component?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 07 May 2013 14:12:52 -0300, George Ludwig <ge...@gmail.com>  
wrote:

> I'm trying to use the Dynamic component so I can specify the tml at  
> runtime.

Notice the template parameter is of type Asset, so that's what you should  
pass to it. The default binding is 'asset', and I guess you overlooked  
this important fact. Use the AssetSource service instead. Something like  
this:

@Inject
private AssetSource assetSource;

public Asset getTemplate() {
	// use AssertSource to get the Asset
}

<t:dynamic template="prop:template"/>

> These work:
>
> <t:dynamic template="myTemplate.tml" ...
>
> <t:dynamic template="asset:myTemplate.tml" ...
>
>
> But I need to read the template name from a property. Unfortunately,  
> these
> do not work:
>
> <t:dynamic template="templateName" ... (where templateName is a String
> property)

It won't work because the default binding of the parameter is Asset.

> <t:dynamic template="${templateName}" ... (where templateName is a String
> property)

Never, never, never ever use expansions when passing component parameter  
values.

> <t:dynamic template="prop:templateName" ... (where templateName is a  
> String property)

It won't work because the default binding of the parameter is Asset.

> <t:dynamic template="asset:templateName}" ... (where templateName is a
> String property)

The asset binding doesn't support properties.

> <t:dynamic template="asset:${templateName}" ... (where templateName is a
> String property)

The asset binding doesn't support ${}

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org