Hello everyone,

   I want to create an edit form and I'm trying to set the selected item 
of a DropDownChoice to match what I have in the database.

The form constructor looks like this:
public ClientEditPage(Client c) {...}

The code that sets the form looks like this:

final static List OPTIONS = Arrays.asList(new String[] {"Opt1", "Opt2", 


DropDownChoice ddc = new DropDownChoice(
        new Model(c.getMyOptionValue()),
        new ChoiceRenderer() {
                public String getIdValue(Object arg0, int arg1) {
                // I also tried to return ((Integer)arg1).toString()
                // and it didn't work
                return ((Integer)OPTIONS.indexOf(arg0)).toString();
){      protected String getDefaultChoice(final Object selected)
        return ""; // remove "Choose One" prompt


No matter what client I select, it always shows me the first option. 
Also, the rendered HTML looks like this:
<option value="0">Opt1</option>
<option value="1">Opt2</option>
<option value="2">Opt3</option>

No selected="selected" attribute.

Can somebody tell me what am I doing wrong?

Thank you in advance,
- posto

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
Wicket-user mailing list

Reply via email to