Re: DropDownChoice with Java Enum
also just use or extend ChoiceRenderer which might already > do > >> > what you want... > >> > For example > >> > new ChoiceRenderer("description", "value") > >> > > >> > Matt > >> > > >> > cmoulliard wrote: > >> >> You mean create something like this : > >> >> > >> >> add(new DropDownChoice("requestStatus", > >> >> Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { > >> >> > >> >> public Object getDisplayValue(Object objDispl) { > >> >> return > >> ProcessingStatusType.valueOf((String) > >> >> objDispl).getDescription(); > >> >> } > >> >> > >> >> public String getIdValue(Object obj, int index) > { > >> >> return obj.toString(); > >> >> }})); > >> >> > >> >> I have an error during initialisation : > >> >> > >> >> WicketMessage: Exception in rendering component: [MarkupContainer > >> >> [Component > >> >> id = requestStatus]] > >> >> > >> >> Root cause: > >> >> > >> >> java.lang.ClassCastException: > >> >> com.xpectis.x3s.model.usertype.ProcessingStatusType > >> >> at > >> >> > >> > com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) > >> >> > >> >> I suppose that what I defined in getDisplayValue is not correct ? > >> >> > >> >> Matthias Keller wrote: > >> >> > >> >>> Hi Charles > >> >>> > >> >>> No problem. Just make an IChoiceRenderer which calls getDescription > >> for > >> >>> the display value and getValue for the id. > >> >>> > >> >>> Matt > >> >>> > >> >>> Charles Moulliard wrote: > >> >>> > >> >>>> Hi, > >> >>>> > >> >>>> I would like to know if I can create a DropDownChoice where the > >> value > >> >>>> to > >> >>>> be > >> >>>> displayed in the drop down list corresponds to the description of > my > >> >>>> enumeration (e.g. Accepted) while the value to be returned is the > >> value > >> >>>> defined in the enumeration (e.g: ACCPT) ? > >> >>>> > >> >>>> public enum ProcessingStatusType { > >> >>>> NEW ("NEW", "New"), > >> >>>> ACCEPTED ("ACCPT", "Accepted"), > >> >>>> VALIDATED ("VALID", "Validated"), > >> >>>> TRANSFORMED("TRFRM", "Transformed"), > >> >>>> TRANSFERRED("TRFRD", "Transferred"), > >> >>>> REJECTED("REJEC", "Rejected"), > >> >>>> FAILED("FAIL", "Failed"); > >> >>>> > >> >>>> private final String value; > >> >>>> private final String description; > >> >>>> > >> >>>> ProcessingStatusType( String value, String description ) { > >> >>>> this.value = value; > >> >>>> this.description = description; > >> >>>> } > >> >>>> > >> >>>> > >> >>>> > >> > > >> > > >> > > >> > >> > >> - > >> Charles Moulliard > >> SOA Architect > >> > >> My Blog : http://cmoulliard.blogspot.com/ > >> http://cmoulliard.blogspot.com/ > >> -- > >> View this message in context: > >> > http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25385339.html > >> Sent from the Wicket - User mailing list archive at Nabble.com. > >> > >> > >> - > >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >> For additional commands, e-mail: users-h...@wicket.apache.org > >> > >> > > > > > > > - > Charles Moulliard > SOA Architect > > My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ > -- > View this message in context: > http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25396006.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: DropDownChoice with Java Enum
ption: >> >> com.xpectis.x3s.model.usertype.ProcessingStatusType >> >> at >> >> >> com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) >> >> >> >> I suppose that what I defined in getDisplayValue is not correct ? >> >> >> >> Matthias Keller wrote: >> >> >> >>> Hi Charles >> >>> >> >>> No problem. Just make an IChoiceRenderer which calls getDescription >> for >> >>> the display value and getValue for the id. >> >>> >> >>> Matt >> >>> >> >>> Charles Moulliard wrote: >> >>> >> >>>> Hi, >> >>>> >> >>>> I would like to know if I can create a DropDownChoice where the >> value >> >>>> to >> >>>> be >> >>>> displayed in the drop down list corresponds to the description of my >> >>>> enumeration (e.g. Accepted) while the value to be returned is the >> value >> >>>> defined in the enumeration (e.g: ACCPT) ? >> >>>> >> >>>> public enum ProcessingStatusType { >> >>>> NEW ("NEW", "New"), >> >>>> ACCEPTED ("ACCPT", "Accepted"), >> >>>> VALIDATED ("VALID", "Validated"), >> >>>> TRANSFORMED("TRFRM", "Transformed"), >> >>>> TRANSFERRED("TRFRD", "Transferred"), >> >>>> REJECTED("REJEC", "Rejected"), >> >>>> FAILED("FAIL", "Failed"); >> >>>> >> >>>> private final String value; >> >>>> private final String description; >> >>>> >> >>>> ProcessingStatusType( String value, String description ) { >> >>>> this.value = value; >> >>>> this.description = description; >> >>>> } >> >>>> >> >>>> >> >>>> >> > >> > >> > >> >> >> - >> Charles Moulliard >> SOA Architect >> >> My Blog : http://cmoulliard.blogspot.com/ >> http://cmoulliard.blogspot.com/ >> -- >> View this message in context: >> http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25385339.html >> Sent from the Wicket - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > > - Charles Moulliard SOA Architect My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ -- View this message in context: http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25396006.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice with Java Enum
The value on model are on ProcessingStatusType instance. Use ((ProcessingStatusType)model.getObject()).getValue() to access the value REJEC On Thu, Sep 10, 2009 at 12:39 PM, cmoulliard wrote: > > Thks for all. > > With the following syntax : > >add(new DropDownChoice("requestStatus", > Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { > > public Object getDisplayValue(Object status) { >return ((ProcessingStatusType) > status).getDescription(); >} > >public String getIdValue(Object status, int index) { >return ((ProcessingStatusType) > status).getValue(); >}})); > > html generated : > > > Choose One > New > Accepted > > Validated > Transformed > Transferred > Rejected > Failed > > > Everything is ok except that the value receives by my RequestFormModel > after > the post is equal to the description (e.g : REJECTED instead of REJEC) and > not the value > > > > > > > Here is what I have in html : > > > > Matthias Keller wrote: > > > > Hi > > > > Close but not quite. getDisplayValue gets the catual ELEMENT of the list > > - so objDispl is of type ProcessingStatusType already. > > So in your case it would be something like: > > > >> public Object getDisplayValue(Object objDispl) { > >> return ((ProcessingStatusType) objDispl).getDescription(); > >> } > >> > >> public String getIdValue(Object obj, int index) { > >> return obj.toString(); > >> // or if you prefer to have the value of your enum in the HTML > code: > >> // return ((ProcessingStatusType) objDispl).getValue() > >> } > > Which one of the getIdValue implementations you chose doesn't matter for > > wicket, it just needs an ID for every entry which is unique. > > In your case you could even return String.valueOf(index) as your > > backing List of the Enums will not ever change while deployed. > > > > Be careful though with using index, there are circumstances where no > > useful index will be provided (always -1) - That happens when you > > externally change the selected value of the DropDownChoice. > > > > you could also just use or extend ChoiceRenderer which might already do > > what you want... > > For example > > new ChoiceRenderer("description", "value") > > > > Matt > > > > cmoulliard wrote: > >> You mean create something like this : > >> > >> add(new DropDownChoice("requestStatus", > >> Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { > >> > >> public Object getDisplayValue(Object objDispl) { > >> return > ProcessingStatusType.valueOf((String) > >> objDispl).getDescription(); > >> } > >> > >> public String getIdValue(Object obj, int index) { > >> return obj.toString(); > >> }})); > >> > >> I have an error during initialisation : > >> > >> WicketMessage: Exception in rendering component: [MarkupContainer > >> [Component > >> id = requestStatus]] > >> > >> Root cause: > >> > >> java.lang.ClassCastException: > >> com.xpectis.x3s.model.usertype.ProcessingStatusType > >> at > >> > com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) > >> > >> I suppose that what I defined in getDisplayValue is not correct ? > >> > >> Matthias Keller wrote: > >> > >>> Hi Charles > >>> > >>> No problem. Just make an IChoiceRenderer which calls getDescription for > >>> the display value and getValue for the id. > >>> > >>> Matt > >>> > >>> Charles Moulliard wrote: > >>> > >>>> Hi, > >>>> > >>>> I would like to know if I can create a DropDownChoice where the value > >>>> to > >>>> be > >>>> displayed in the drop down list corresponds to the description of my > >>>> enumeration (e.g. Accepted) while the value to be returned is the > value > >>>> defined in the enumeration (e.g: ACCPT) ? > >>>
Re: DropDownChoice with Java Enum
Thks for all. With the following syntax : add(new DropDownChoice("requestStatus", Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { public Object getDisplayValue(Object status) { return ((ProcessingStatusType) status).getDescription(); } public String getIdValue(Object status, int index) { return ((ProcessingStatusType) status).getValue(); }})); html generated : Choose One New Accepted Validated Transformed Transferred Rejected Failed Everything is ok except that the value receives by my RequestFormModel after the post is equal to the description (e.g : REJECTED instead of REJEC) and not the value Here is what I have in html : Matthias Keller wrote: > > Hi > > Close but not quite. getDisplayValue gets the catual ELEMENT of the list > - so objDispl is of type ProcessingStatusType already. > So in your case it would be something like: > >> public Object getDisplayValue(Object objDispl) { >> return ((ProcessingStatusType) objDispl).getDescription(); >> } >> >> public String getIdValue(Object obj, int index) { >> return obj.toString(); >> // or if you prefer to have the value of your enum in the HTML code: >> // return ((ProcessingStatusType) objDispl).getValue() >> } > Which one of the getIdValue implementations you chose doesn't matter for > wicket, it just needs an ID for every entry which is unique. > In your case you could even return String.valueOf(index) as your > backing List of the Enums will not ever change while deployed. > > Be careful though with using index, there are circumstances where no > useful index will be provided (always -1) - That happens when you > externally change the selected value of the DropDownChoice. > > you could also just use or extend ChoiceRenderer which might already do > what you want... > For example > new ChoiceRenderer("description", "value") > > Matt > > cmoulliard wrote: >> You mean create something like this : >> >> add(new DropDownChoice("requestStatus", >> Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { >> >> public Object getDisplayValue(Object objDispl) { >> return ProcessingStatusType.valueOf((String) >> objDispl).getDescription(); >> } >> >> public String getIdValue(Object obj, int index) { >> return obj.toString(); >> }})); >> >> I have an error during initialisation : >> >> WicketMessage: Exception in rendering component: [MarkupContainer >> [Component >> id = requestStatus]] >> >> Root cause: >> >> java.lang.ClassCastException: >> com.xpectis.x3s.model.usertype.ProcessingStatusType >> at >> com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) >> >> I suppose that what I defined in getDisplayValue is not correct ? >> >> Matthias Keller wrote: >> >>> Hi Charles >>> >>> No problem. Just make an IChoiceRenderer which calls getDescription for >>> the display value and getValue for the id. >>> >>> Matt >>> >>> Charles Moulliard wrote: >>> >>>> Hi, >>>> >>>> I would like to know if I can create a DropDownChoice where the value >>>> to >>>> be >>>> displayed in the drop down list corresponds to the description of my >>>> enumeration (e.g. Accepted) while the value to be returned is the value >>>> defined in the enumeration (e.g: ACCPT) ? >>>> >>>> public enum ProcessingStatusType { >>>> NEW ("NEW", "New"), >>>> ACCEPTED ("ACCPT", "Accepted"), >>>> VALIDATED ("VALID", "Validated"), >>>> TRANSFORMED("TRFRM", "Transformed"), >>>> TRANSFERRED("TRFRD", "Transferred"), >>>> REJECTED("REJEC", "Rejected"), >>>> FAILED("FAIL", "Failed"); >>>> >>>> private final String value; >>>> private final String description; >>>> >>>> ProcessingStatusType( String value, String description ) { >>>> this.value = value; >>>> this.description = description; >>>> } >>>> >>>> >>>> > > > - Charles Moulliard SOA Architect My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ -- View this message in context: http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25385339.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice with Java Enum
You cast objDispl to String which is obviously(?) a ProcessingStatusType cmoulliard wrote: > You mean create something like this : > > add(new DropDownChoice("requestStatus", > Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { > > public Object getDisplayValue(Object objDispl) { > return ProcessingStatusType.valueOf((String) > objDispl).getDescription(); > } > > public String getIdValue(Object obj, int index) { > return obj.toString(); > }})); > > I have an error during initialisation : > > WicketMessage: Exception in rendering component: [MarkupContainer [Component > id = requestStatus]] > > Root cause: > > java.lang.ClassCastException: > com.xpectis.x3s.model.usertype.ProcessingStatusType > at > com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) > > I suppose that what I defined in getDisplayValue is not correct ? > > Matthias Keller wrote: >> Hi Charles >> >> No problem. Just make an IChoiceRenderer which calls getDescription for >> the display value and getValue for the id. >> >> Matt >> >> Charles Moulliard wrote: >>> Hi, >>> >>> I would like to know if I can create a DropDownChoice where the value to >>> be >>> displayed in the drop down list corresponds to the description of my >>> enumeration (e.g. Accepted) while the value to be returned is the value >>> defined in the enumeration (e.g: ACCPT) ? >>> >>> public enum ProcessingStatusType { >>> NEW ("NEW", "New"), >>> ACCEPTED ("ACCPT", "Accepted"), >>> VALIDATED ("VALID", "Validated"), >>> TRANSFORMED("TRFRM", "Transformed"), >>> TRANSFERRED("TRFRD", "Transferred"), >>> REJECTED("REJEC", "Rejected"), >>> FAILED("FAIL", "Failed"); >>> >>> private final String value; >>> private final String description; >>> >>> ProcessingStatusType( String value, String description ) { >>> this.value = value; >>> this.description = description; >>> } >>> >>> >> >> >> > > > - > Charles Moulliard > SOA Architect > > My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice with Java Enum
Hi Close but not quite. getDisplayValue gets the catual ELEMENT of the list - so objDispl is of type ProcessingStatusType already. So in your case it would be something like: public Object getDisplayValue(Object objDispl) { return ((ProcessingStatusType) objDispl).getDescription(); } public String getIdValue(Object obj, int index) { return obj.toString(); // or if you prefer to have the value of your enum in the HTML code: // return ((ProcessingStatusType) objDispl).getValue() } Which one of the getIdValue implementations you chose doesn't matter for wicket, it just needs an ID for every entry which is unique. In your case you could even return String.valueOf(index) as your backing List of the Enums will not ever change while deployed. Be careful though with using index, there are circumstances where no useful index will be provided (always -1) - That happens when you externally change the selected value of the DropDownChoice. you could also just use or extend ChoiceRenderer which might already do what you want... For example new ChoiceRenderer("description", "value") Matt cmoulliard wrote: You mean create something like this : add(new DropDownChoice("requestStatus", Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { public Object getDisplayValue(Object objDispl) { return ProcessingStatusType.valueOf((String) objDispl).getDescription(); } public String getIdValue(Object obj, int index) { return obj.toString(); }})); I have an error during initialisation : WicketMessage: Exception in rendering component: [MarkupContainer [Component id = requestStatus]] Root cause: java.lang.ClassCastException: com.xpectis.x3s.model.usertype.ProcessingStatusType at com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) I suppose that what I defined in getDisplayValue is not correct ? Matthias Keller wrote: Hi Charles No problem. Just make an IChoiceRenderer which calls getDescription for the display value and getValue for the id. Matt Charles Moulliard wrote: Hi, I would like to know if I can create a DropDownChoice where the value to be displayed in the drop down list corresponds to the description of my enumeration (e.g. Accepted) while the value to be returned is the value defined in the enumeration (e.g: ACCPT) ? public enum ProcessingStatusType { NEW ("NEW", "New"), ACCEPTED ("ACCPT", "Accepted"), VALIDATED ("VALID", "Validated"), TRANSFORMED("TRFRM", "Transformed"), TRANSFERRED("TRFRD", "Transferred"), REJECTED("REJEC", "Rejected"), FAILED("FAIL", "Failed"); private final String value; private final String description; ProcessingStatusType( String value, String description ) { this.value = value; this.description = description; } smime.p7s Description: S/MIME Cryptographic Signature
Re: DropDownChoice with Java Enum
@Override public String getDisplayValue(Object status) { return ((ProcessingStatusType) status).getDescription(); } On Thu, Sep 10, 2009 at 9:46 AM, cmoulliard wrote: > > You mean create something like this : > > add(new DropDownChoice("requestStatus", > Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { > >public Object getDisplayValue(Object objDispl) { >return ProcessingStatusType.valueOf((String) > objDispl).getDescription(); >} > >public String getIdValue(Object obj, int index) { >return obj.toString(); >}})); > > I have an error during initialisation : > > WicketMessage: Exception in rendering component: [MarkupContainer > [Component > id = requestStatus]] > > Root cause: > > java.lang.ClassCastException: > com.xpectis.x3s.model.usertype.ProcessingStatusType > at > > com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) > > I suppose that what I defined in getDisplayValue is not correct ? > > Matthias Keller wrote: > > > > Hi Charles > > > > No problem. Just make an IChoiceRenderer which calls getDescription for > > the display value and getValue for the id. > > > > Matt > > > > Charles Moulliard wrote: > >> Hi, > >> > >> I would like to know if I can create a DropDownChoice where the value to > >> be > >> displayed in the drop down list corresponds to the description of my > >> enumeration (e.g. Accepted) while the value to be returned is the value > >> defined in the enumeration (e.g: ACCPT) ? > >> > >> public enum ProcessingStatusType { > >> NEW ("NEW", "New"), > >> ACCEPTED ("ACCPT", "Accepted"), > >> VALIDATED ("VALID", "Validated"), > >> TRANSFORMED("TRFRM", "Transformed"), > >> TRANSFERRED("TRFRD", "Transferred"), > >> REJECTED("REJEC", "Rejected"), > >> FAILED("FAIL", "Failed"); > >> > >> private final String value; > >> private final String description; > >> > >> ProcessingStatusType( String value, String description ) { > >> this.value = value; > >> this.description = description; > >> } > >> > >> > > > > > > > > > > > - > Charles Moulliard > SOA Architect > > My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ > -- > View this message in context: > http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25382688.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: DropDownChoice with Java Enum
Please use debugger to find out.. 2009/9/10 cmoulliard : > > You mean create something like this : > > add(new DropDownChoice("requestStatus", > Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { > > public Object getDisplayValue(Object objDispl) { > return ProcessingStatusType.valueOf((String) > objDispl).getDescription(); > } > > public String getIdValue(Object obj, int index) { > return obj.toString(); > }})); > > I have an error during initialisation : > > WicketMessage: Exception in rendering component: [MarkupContainer [Component > id = requestStatus]] > > Root cause: > > java.lang.ClassCastException: > com.xpectis.x3s.model.usertype.ProcessingStatusType > at > com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) > > I suppose that what I defined in getDisplayValue is not correct ? > > Matthias Keller wrote: >> >> Hi Charles >> >> No problem. Just make an IChoiceRenderer which calls getDescription for >> the display value and getValue for the id. >> >> Matt >> >> Charles Moulliard wrote: >>> Hi, >>> >>> I would like to know if I can create a DropDownChoice where the value to >>> be >>> displayed in the drop down list corresponds to the description of my >>> enumeration (e.g. Accepted) while the value to be returned is the value >>> defined in the enumeration (e.g: ACCPT) ? >>> >>> public enum ProcessingStatusType { >>> NEW ("NEW", "New"), >>> ACCEPTED ("ACCPT", "Accepted"), >>> VALIDATED ("VALID", "Validated"), >>> TRANSFORMED("TRFRM", "Transformed"), >>> TRANSFERRED("TRFRD", "Transferred"), >>> REJECTED("REJEC", "Rejected"), >>> FAILED("FAIL", "Failed"); >>> >>> private final String value; >>> private final String description; >>> >>> ProcessingStatusType( String value, String description ) { >>> this.value = value; >>> this.description = description; >>> } >>> >>> >> >> >> >> > > > - > Charles Moulliard > SOA Architect > > My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ > -- > View this message in context: > http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25382688.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice with Java Enum
You mean create something like this : add(new DropDownChoice("requestStatus", Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() { public Object getDisplayValue(Object objDispl) { return ProcessingStatusType.valueOf((String) objDispl).getDescription(); } public String getIdValue(Object obj, int index) { return obj.toString(); }})); I have an error during initialisation : WicketMessage: Exception in rendering component: [MarkupContainer [Component id = requestStatus]] Root cause: java.lang.ClassCastException: com.xpectis.x3s.model.usertype.ProcessingStatusType at com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38) I suppose that what I defined in getDisplayValue is not correct ? Matthias Keller wrote: > > Hi Charles > > No problem. Just make an IChoiceRenderer which calls getDescription for > the display value and getValue for the id. > > Matt > > Charles Moulliard wrote: >> Hi, >> >> I would like to know if I can create a DropDownChoice where the value to >> be >> displayed in the drop down list corresponds to the description of my >> enumeration (e.g. Accepted) while the value to be returned is the value >> defined in the enumeration (e.g: ACCPT) ? >> >> public enum ProcessingStatusType { >> NEW ("NEW", "New"), >> ACCEPTED ("ACCPT", "Accepted"), >> VALIDATED ("VALID", "Validated"), >> TRANSFORMED("TRFRM", "Transformed"), >> TRANSFERRED("TRFRD", "Transferred"), >> REJECTED("REJEC", "Rejected"), >> FAILED("FAIL", "Failed"); >> >> private final String value; >> private final String description; >> >> ProcessingStatusType( String value, String description ) { >> this.value = value; >> this.description = description; >> } >> >> > > > > - Charles Moulliard SOA Architect My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ -- View this message in context: http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25382688.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DropDownChoice with Java Enum
Hi Charles No problem. Just make an IChoiceRenderer which calls getDescription for the display value and getValue for the id. Matt Charles Moulliard wrote: Hi, I would like to know if I can create a DropDownChoice where the value to be displayed in the drop down list corresponds to the description of my enumeration (e.g. Accepted) while the value to be returned is the value defined in the enumeration (e.g: ACCPT) ? public enum ProcessingStatusType { NEW ("NEW", "New"), ACCEPTED ("ACCPT", "Accepted"), VALIDATED ("VALID", "Validated"), TRANSFORMED("TRFRM", "Transformed"), TRANSFERRED("TRFRD", "Transferred"), REJECTED("REJEC", "Rejected"), FAILED("FAIL", "Failed"); private final String value; private final String description; ProcessingStatusType( String value, String description ) { this.value = value; this.description = description; } smime.p7s Description: S/MIME Cryptographic Signature
DropDownChoice with Java Enum
Hi, I would like to know if I can create a DropDownChoice where the value to be displayed in the drop down list corresponds to the description of my enumeration (e.g. Accepted) while the value to be returned is the value defined in the enumeration (e.g: ACCPT) ? public enum ProcessingStatusType { NEW ("NEW", "New"), ACCEPTED ("ACCPT", "Accepted"), VALIDATED ("VALID", "Validated"), TRANSFORMED("TRFRM", "Transformed"), TRANSFERRED("TRFRD", "Transferred"), REJECTED("REJEC", "Rejected"), FAILED("FAIL", "Failed"); private final String value; private final String description; ProcessingStatusType( String value, String description ) { this.value = value; this.description = description; } Regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer * blog : http://cmoulliard.blogspot.com