You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Gervais <ge...@polymedis.com> on 2007/11/27 12:53:58 UTC

Display enum in a RadioChoice

Hi all,

I need to display a enum in a RadioChoice. So i'm doing that :

    public static enum Genre { Male, Female }
    private static List GENRES = Arrays.asList(Person.Genre.values());
    ...
    add(new RadioChoice("student.genre", GENRES));
    ...

It work but displaying avlues Are "Male" and "Female" and i'm french so 
i prefer "Masculin" and "Feminin" or (better in my case) "M" and "F".
I don't need to overload toString in my enum because i think Genre is in 
the model and my model doesn't have to change with langage.

->  How can i render "M" or "F" instead of "Male" or "Female" ?

Thanks

Re: Display enum in a RadioChoice

Posted by Jonas <ba...@gmail.com>.
> Yes i've considered RadioGroup and Radio but my question was also for
> other components (in fact i need to set the class of <option>, and
> <input> tag and surrely many others)

have a look at AttributeModifier and AttributeAppender.

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


Re: Display enum in a RadioChoice

Posted by Gervais <ge...@polymedis.com>.
Ok, thank you for the setSuffix() and setPrefix().

Yes i've considered RadioGroup and Radio but my question was also for 
other components (in fact i need to set the class of <option>, and 
<input> tag and surrely many others)


Jonas a écrit :
> The '<br/>' is the default suffix (see RadioChoice#setSuffix and
> RadioChoice#setPrefix).
>
> AFAIK there's no way to set a class attribute using RadioChoice. Have
> you considered
> using RadioGroup and Radio? They're much more flexible than RadioChoice.
>
>
> On Nov 27, 2007 2:56 PM, Gervais <ge...@polymedis.com> wrote:
>   
>> Ok, thanks.
>>
>> But if i need to set a class name for each items how can i do that ?
>> I need to get and output like that :
>>     <input type="radio" class="genre male" ... />
>>
>> And maybe can i also remove the '<br />' between each radio ?
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> __________ NOD32 2688 (20071127) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
>
>   

Re: Display enum in a RadioChoice

Posted by Jonas <ba...@gmail.com>.
The '<br/>' is the default suffix (see RadioChoice#setSuffix and
RadioChoice#setPrefix).

AFAIK there's no way to set a class attribute using RadioChoice. Have
you considered
using RadioGroup and Radio? They're much more flexible than RadioChoice.


On Nov 27, 2007 2:56 PM, Gervais <ge...@polymedis.com> wrote:
> Ok, thanks.
>
> But if i need to set a class name for each items how can i do that ?
> I need to get and output like that :
>     <input type="radio" class="genre male" ... />
>
> And maybe can i also remove the '<br />' between each radio ?

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


Re: Display enum in a RadioChoice

Posted by Gervais <ge...@polymedis.com>.
Ok, thanks.

But if i need to set a class name for each items how can i do that ?
I need to get and output like that :
    <input type="radio" class="genre male" ... />

And maybe can i also remove the '<br />' between each radio ?



Jonas a écrit :
> Hi,
>
> some constructors of RadioChoice take a
> org.apache.wicket.markup.html.form.IChoiceRenderer,
> which is used to render the choices.
>
> cheers,
> Jonas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
> __________ NOD32 2688 (20071127) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
>
>   

Re: Display enum in a RadioChoice

Posted by Jonas <ba...@gmail.com>.
Hi,

some constructors of RadioChoice take a
org.apache.wicket.markup.html.form.IChoiceRenderer,
which is used to render the choices.

cheers,
Jonas

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