This peaked my interest so a colleague of mine and I talked about it and came
up with this working example:
jsp:
<s:select name="color" list="@my.package.Color@values()" listKey="name()"
listValue="description"></s:select>
action:
private String color; // "RED", "GREEN", or "BLUE"
Color selectedColor = Color.valueOf(color);
enum:
public enum Color {
RED ("Red"),
GREEN ("Green"),
BLUE ("Blue");
private String description;
Color(String newDescription){
this.description = newDescription;
}
public String getDescription(){
return this.description;
}
}
Cool!
Beez
> -----Original Message-----
> From: Steven Yang [mailto:[email protected]]
> Sent: Thursday, May 12, 2011 9:03 PM
> To: Struts Users Mailing List
> Subject: Re: Iterator tag and enumeration
>
> I dont quite get what exactly you want
>
> if your getListLocalization has all the information of you
> Enum then you probably just do list="listLocalization.entrySet"
> but then you still need to provide the listValue and listKey attribute
>
> On Thu, May 12, 2011 at 6:56 PM, <[email protected]> wrote:
>
> > This code is working :
> > <s:select
> list="@org.ensam.annuaire.enumeration.Localization@values()"
> > />
> >
> > This one is not working :
> > <s:select
> >
> list="@org.ensam.annuaire.enumeration.Localization@getListLoca
> lization ()" /> Neither this one :
> > <s:select
> >
> list="@org.ensam.annuaire.enumeration.Localization@listLocaliz
> ation ()" /> And neither this one :
> > <s:select
> >
> list="@org.ensam.annuaire.enumeration.Localization@listLocalization "
> > />
> >
> > I would be great to make the getListLocalization() work
> because I will
> > be able to have a nice display of select element.
> >
> > Thank
> >
> > Matthieu MARC
> >
> >
> > -----Message d'origine-----
> > De : Steven Yang [mailto:[email protected]] Envoyé :
> jeudi 12 mai
> > 2011 12:34 À : Struts Users Mailing List Objet : Re:
> Iterator tag and
> > enumeration
> >
> > try
> > <s:select list="@{full package name}.Localization@values()"/>
> >
> > On Thu, May 12, 2011 at 3:33 PM, <[email protected]> wrote:
> >
> > > Hi,
> > >
> > > I have an enumeration 'Localization' :
> > >
> > > public enum Localization {
> > >
> > > AIX("Aix-en-provence"),
> > > ANGERS("Angers") ;
> > > }
> > >
> > > And I want to put a form select in a jsp using s:select
> tag with all
> > > Localization items, like :
> > >
> > > <s:select list="Localization enum"/>
> > >
> > > But I don't know what to put in the list parameter.
> > >
> > > In my Localization enum, I wrote a function to retrieve
> Localization
> > > item through a sorted map :
> > >
> > > public Map<String, String> getListLocalization() {
> > > [...]
> > > }
> > >
> > > So that my select will be like : <option
> > > value="aix">Aix-en-provence</option>
> > >
> > > My question is finally : how to put an enumeration in a
> s:select tag ?
> > >
> > > Thanks,
> > >
> > > Matthieu MARC
> > >
> > > ---
> > > Matthieu MARC
> > > Responsable du Service Informatique du Centre d'Angers Arts et
> > > Métiers ParisTech Tél : 02 41 20 73 61
> > >
> > >
> > >
> --------------------------------------------------------------------
> > > - 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]
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]