Hello Everybody

I'm using wicket.markup.html.form.DropDownChoice and it
works fine until now, when I got a suspicious behavior (maybe bug)

Into database I have one data called "TEMP CUSTOMER" that has 
id = -1 (it's business logic of our client, that data came through
database importation, and I can not update that data)

Following my code:

List relations = relationManager.list();
  final DropDownChoice ddRelations = new DropDownChoice("relation", 
(task.getRelation() == null) ? new Model() : new Model(task.getRelation()), 
relations, new IChoiceRenderer() {
    public Object getDisplayValue(Object object) {
 return ((Relation) object).getName();
    }
    public String getIdValue(Object object, int index) {
 return String.valueOf(((Relation) object).getId());
    }
  }); 
form.add(ddRelations);


and HERE is the source code generate on html :

<select name="relation">
<option selected="selected" value="">Choose one</option>
<option selected="selected" value="-1">TEMP CUSTOMER</option>
<option value="1">CUSTOMER 1</option>
<option value="2">CUSTOMER 2</option> .. and so on ...

As you can see, there are two options with selected attribute,  
therefore always "TEMP CUSTOMER" will be selected.

When I saw this, I though why in all other dropdownchoices 
that I had already implemented following the same sample are working very well 
? 
I had no doubts, and I changed the TEMP CUSTOMER id 
on database to "1" and ... sup.. the dropdownchoice works fine.

But I can't change that data, so I rollback, and also the 
problem rollback.

I ask to you , experts guys, if I put a negative value into a 
dropdownchoice, it will be the default value if none is selected ?
How I can do "Choose one" be the default value in this specific case ?
Any idea to solve this problem ?

Thank you

Best Regards 

Juliano

Reply via email to