You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bob Harner <bo...@gmail.com> on 2011/07/23 23:06:46 UTC

Re: select component

Tony,

Sorry I didn't reply to this earlier. I'm sure you figured it out by
now, but for the record the canonical answer comes from Tapestry's own
TapestryModule class
(http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?view=markup),
which is equivalent to your code:

    @SuppressWarnings("all")
    public static void
contributeValueEncoderSource(MappedConfiguration<Class, Object>
configuration)
    {
        configuration.addInstance(Object.class,
TypeCoercedValueEncoderFactory.class);
        configuration.add(String.class, new StringValueEncoder());
        configuration.add(Enum.class, new EnumValueEncoderFactory());
    }

On Sun, Jun 26, 2011 at 4:32 PM, Tony Nelson <tn...@starpoint.com> wrote:
> Is this the "correct" way to contribute multiple ValueEncoders?
>
>    @SuppressWarnings("unchecked")
>    public static void contributeValueEncoderSource(MappedConfiguration configuration) {
>        configuration.addInstance(Group.class, GroupEncoder.class);
>        configuration.addInstance(Office.class, OfficeEncoder.class);
>    }
>
>
> Is there a way to tell Tap to look in a specific package and register all the ValueEncoders it finds?
>
> Thanks
> Tony
>
> On Jun 26, 2011, at 2:57 PM, Bob Harner wrote:
>
>> Tony,
>>
>> The menu options are determined by your SelectModel. Rather than using
>> your "groups" list as the select model, use SelectModelFactory to
>> generate a SelectModel for you, specifying the attribute to be used
>> for the visible options. See the SelectWithListDemo.java example at
>> http://tapestry.apache.org/using-select-with-a-list.html and let me
>> know if anything in that page isn't clear.
>>
>> On Sun, Jun 26, 2011 at 1:09 PM, Tony Nelson <tn...@starpoint.com> wrote:
>>> Following the sample here: http://tapestry.apache.org/using-select-with-a-list.html
>>>
>>> I created a ValueEncoder and ValueEncoderFactory for my select model.  That was simple enough.  I created the actual select like this:
>>>
>>> <t:select t:id="groupSelect" blankLabel="[ ALL ]" model="groups" value="searchKeys.group" />
>>>
>>> Is it possible to tell the select which attribute of my model should be used to generate the options? It seems to call toString() by default which isn't appropriate for this model.
>>>
>>> Thanks
>>> Tony Nelson
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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