On Wed, 23 Apr 2014 22:54:20 -0300, Paul Stanton <[email protected]> wrote:

Hi all,

Hi!


My component class has a method as such:

public MyEnum getMyEnum1()...


If I use the property binding for 'value' it is treated as its 'EnumType' which is compatible with the encoder...

<t:radiogroup value="selected" encoder="myEnumEncoder">
     <t:radio t:id="myEnum1" value="myEnum1" />


...however using the 'evaluated' binding the 'value' is converted to a String

<t:radiogroup value="selected" encoder="myEnumEncoder">
     <t:radio t:id="myEnum1" value="${getMyEnum1()}" />

I would have expected the two methods to behave identically.

I'm sorry, your expectation is very wrong. That's expected behavior. ${} always coerces the result to a String. That's what it does. It's meant to be used to include dynamic stuff into templates, not bind parameters.

Never, never, ever use ${} when binding parameters. It's always wrong (your case as an example) or useless, so let's keep it simple and have a single rule for all situations> never use ${} when binding parameters. N-e-v-e-r. I've said this almost 50 times on this mailing list already. :P

The reason it would be nice if the 2nd worked is that if there are 1000 different potential values, I could parametrise the method and cut down the code in my component class.

Why can't you do the same in method one? Put it inside a loop, problem solved.

@Property
private MyEnum myEnumValue;

<t:radiogroup value="selected" encoder="myEnumEncoder">
        <t:loop source="myEnums" value="myEnumValue">
                <t:radio t:id="myEnum1" value="myEnumValue" />
        </t:loop>
</t:radiogroup>

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to