You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nicolas Barrera <nb...@gmail.com> on 2013/08/16 17:05:18 UTC

changing t:type binding prefix

Hi,

I 've tried to dynamically change the t:type attribute of an input
textfield by doing this:

<input t:type="prop:elementType"

the page class has a getElementType() method which returns a String with
the name of the desired type.

and I obtained this error:

    Processing of request failed with uncaught exception: Exception
assembling root component of page ivr/CallLogic: Unable to resolve
'prop:elementType' ...


The default binding prefix of t:type for TextField is LITERAL, so I thought
that I could use prop: to change it to PROPERTY but tapestry is still
treating the value as a LITERAL as you can see it looks for a type with
name prop:elementType.

Is that the correct behaviour?

Perhaps this can't be done..., I will use a different approach to do waht I
needed here, but just wanted to ask you why the t:type parameter has that
special behaviour of not accepting other binding prefixes rather than the
LITERAL default.

thank you.


Nicolás.-

Re: changing t:type binding prefix

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 16 Aug 2013 14:06:36 -0300, Nicolas Barrera <nb...@gmail.com>  
wrote:

> Thank you Lance and Thiago,
>
> I was trying to avoid doing this,
>
> <t:if t:test="decideHowToShow">
>
>   <input t:type="TextField" ... />
>
>  <p:else>
>    <input t:type="PasswordField" ... />
>  </p:else>
> </t:if>
>
> or the equivalent blocks and delegate structure.

For the love of everything sacred, please don't use the else block of If.  
It's way confusing.

<t:if t:test="decideHowToShow">
     <input t:type="TextField" ... />
</t:if>
<t:if t:test="!decideHowToShow">
     <input t:type="PasswordField" ... />
</t:if>

> But now I 've learnt that the t:type parameter uses always LITERAL prefix
> and that can't be changed.

I'm sorry, but what you said is completely wrong.

As Lance said, t:type isn't a component parameter, it's a component  
declaration, so talking about bindings about it makes absolutely no sense  
because no binding is used there. What you've really learned today is that  
you cannot declare Tapestry component instances dynamically. ;) In other  
words, Tapestry templates have static structure, but dynamic behavior.

-- 
Thiago H. de Paula Figueiredo

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


Re: changing t:type binding prefix

Posted by Nicolas Barrera <nb...@gmail.com>.
Thank you Lance and Thiago,

I was trying to avoid doing this,

<t:if t:test="decideHowToShow">

  <input t:type="TextField" ... />

 <p:else>
   <input t:type="PasswordField" ... />
 </p:else>
</t:if>

or the equivalent blocks and delegate structure.

But now I 've learnt that the t:type parameter uses always LITERAL prefix
and that can't be changed.

thank you.


Nicolás.-


On Fri, Aug 16, 2013 at 1:46 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 16 Aug 2013 12:05:18 -0300, Nicolas Barrera <nb...@gmail.com>
> wrote:
>
>  Hi,
>>
>
> Hi!
>
>
>  I 've tried to dynamically change the t:type attribute of an input
>> textfield by doing this:
>>
>> <input t:type="prop:elementType"
>>
>
> As Lance said, t:type is the Tapestry component type. This is completely
> unrelated to bindings. The HTML <input> attribute can be set normally, just
> don't use the t: prefix:
>
> <input t:type="TextField" type="${elementType}" ...>
>
> --
> 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: changing t:type binding prefix

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 16 Aug 2013 12:05:18 -0300, Nicolas Barrera <nb...@gmail.com>  
wrote:

> Hi,

Hi!

> I 've tried to dynamically change the t:type attribute of an input
> textfield by doing this:
>
> <input t:type="prop:elementType"

As Lance said, t:type is the Tapestry component type. This is completely  
unrelated to bindings. The HTML <input> attribute can be set normally,  
just don't use the t: prefix:

<input t:type="TextField" type="${elementType}" ...>

-- 
Thiago H. de Paula Figueiredo

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


Re: changing t:type binding prefix

Posted by Lance Java <la...@googlemail.com>.
In tapestry, the "t:type" attribute refers to the component type, and not
the "type" attribute that is rendered in the HTML. One of Tapestry's
principles is static structure, dynamic behaviour so the "t:type" can not
be a runtime value (http://tapestry.apache.org/principles.html)

Tapestry has separate components for each input type (text, checkbox,
submit etc). To pick an input type at runtime you will most likely have a
"block" in your template for each type and use the delegate component to
render one based on some runtime logic.

http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/Delegate.html