Why dont you let handicapaccess be of the type SelectOption. It will contain the getId and getName. So you can get the Y or Yes if you want to. You could ever rename selectoption to HandicapAccessBean to make it clearer. I have created a dropdownchoice that maps to an UUID in the Model instead of the DropDownChoice generic type and I can say I like it. Lets say that your working on a wizard. On the last confirm page you dont want to show Y as the selected handicappaccess. You want to show 'Yes'. That is easiest done by letting the model have the SelectOption as a member! Jens
rhodebump wrote: > > I want to display "Yes" to the user in the dropdown. If the user selects > "Yes", I want address.handicapAccess string property to be set to "Y" > > Do you still think a map-based rendererer is the way to go? > Thank you. > > -----Original Message----- > From: "James Carman" <[email protected]> > Sent: Tuesday, May 5, 2009 7:05am > To: [email protected] > Subject: Re: DropDownChoice with ChoiceRender problem > > So, you want the codes to be the values? Why not use a map-based > renderer as opposed to creating a whole new class? > > On Mon, May 4, 2009 at 9:48 PM, Phillip Rhodes <[email protected]> > wrote: >> It's of type String >> >> Thanks >> >> On May 4, 2009, at 3:23 PM, James Carman wrote: >> >>> The "handicapAccess" property is of type? >>> >>> On Mon, May 4, 2009 at 2:29 PM, Phillip Rhodes >>> <[email protected]> wrote: >>>> >>>> Hi everyone, >>>> Sorry for posting this problem but I have been stuck for far too many >>>> hours on this. Using wicket 1.4 Appreciate any help on this very very >>>> much. >>>> >>>> I have a pojo object called "address" that has a property of >>>> "handicapAccess" >>>> I am trying to bind this property to a dropdown list with 3 choices >>>> (formated as name/value) >>>> Yes/Y >>>> No/N >>>> Unknown/U >>>> >>>> If I use the constructor of ChoiceRenderer(String displayExpression), >>>> No >>>> error, but my property is bound as >>>> com.reffects.dmi.admin.wicket.address.detail.selectopt...@9aa8fd >>>> If I use the constructor of ChoiceRenderer(java.lang.String >>>> displayExpression, java.lang.String idExpression), I get an error >>>> "org.apache.wicket.WicketRuntimeException: No get method defined for >>>> class: >>>> class java.lang.String expression: id" >>>> Although my SelectOption class has getId/setId >>>> >>>> >>>> List<SelectOption> options = new ArrayList<SelectOption>(); >>>> options.add(new SelectOption("Yes", "Y")); >>>> options.add(new SelectOption("No", "N")); >>>> options.add(new SelectOption("Unknown", "U")); >>>> >>>> //org.apache.wicket.WicketRuntimeException: No get method defined for >>>> class: class java.lang.String expression: id >>>> ChoiceRenderer choiceRenderer = new ChoiceRenderer("name","id"); >>>> >>>> //this choice render gives it a >>>> // >>>> <handicapAccess>com.reffects.dmi.admin.wicket.address.detail.selectopt...@9aa8fd</handicapAccess> >>>> //ChoiceRenderer choiceRenderer = new ChoiceRenderer("name"); >>>> PropertyModel model = new PropertyModel(address, "handicapAccess"); >>>> >>>> DropDownChoice ddc = new DropDownChoice("dropDownChoice", >>>> model,options,choiceRenderer); >>>> >>>> >>>> //Here's my SelectOption >>>> public class SelectOption implements Serializable { >>>> /** >>>> * >>>> */ >>>> private static final long serialVersionUID = 1L; >>>> private String name; >>>> private String id; >>>> >>>> public SelectOption(String name, String id) { >>>> this.name = name; >>>> this.id = id; >>>> } >>>> >>>> public String getName() { >>>> return name; >>>> } >>>> >>>> public void setName(String name) { >>>> this.name = name; >>>> } >>>> >>>> public String getId() { >>>> return id; >>>> } >>>> >>>> public void setId(String id) { >>>> this.id = id; >>>> } >>>> >>>> } >>>> >>>> >>>> >>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> 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] >> >> > > --------------------------------------------------------------------- > 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] > > > -- View this message in context: http://www.nabble.com/DropDownChoice-with-ChoiceRender-problem-tp23374394p23389037.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
