try
<s:checkboxlist
list="@my.site.enums.co...@values()"
listKey="label"
listValue="label"
name="colors"
/>
2010/11/19 Altenhof, David Aron <[email protected]>:
> Trying to figure out a way to do the following without much luck.
>
> I have an enumeration with a list of menu options and corresponding labels
> such as:
>
> public enum Color {
> RED("Red"),
> BLUE("Blue"),
> GREEN("Green");
>
> private String myLabel;
> private Color(String label){ this.myLabel = label; }
> public String getLabel(){ return this.myLabel; }
> }
>
> This can be easily used to create a checkboxlist:
>
> <p> Please enter your favorite colors: </p>
> <s:checkboxlist
> list="@my.site.enums.co...@values()"
> listValue="label"
> name="colors"
> />
>
> I also have a set of Color on the Action that came from the persistence layer
> and has a Color for each of the user's (past) choices:
>
> public Set<Color> getColors() {
> return colors;
> }
>
> Question is: How do I automagically "check" the appropriate checkbox if they
> have a corresponding value in getColors? I guess I'm looking for something
> like a databind from other languages.
>
> I suppose one could iterate over the enum and create individual checkboxes
> for each while testing to see if they have an already selected color, but I
> thought there might be a more direct way...
>
> -David
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]