| Hello all.. First of all, I know that this has been discussed here, I searched the archives but could not find an answer, or at least understand one, so please If someone can help me I would greatly appreciate it... I have a small problem with Drop Down Choices and the selected value when editing an existing record... and I wanted to validate that I'm doing things the correct way.. and if so.. if there is a known issue.... the scenario is as follows... I created an extended class (just to simplify my work) to generate DDC from a multivalues tables (aka, a table where one holds different types of things.. countries, cities, status codes, etc..). The rest of the mail will be in RED for readability... In my tables I'm required to store the code and not the value so basically I created the following class..(these are fractions.. I'm attaching the actual clasess..) public class mvDropDownChoice extends DropDownChoice { ... static List mvValues = null; @SuppressWarnings("serial") public mvDropDownChoice(String id, String mvCode, IModel model) { super(id, new PropertyModel(model, id),sysMultivaluesProvider.getMVList(mvCode),new IChoiceRenderer() { public String getDisplayValue(Object object) { SysMultivalues mv = (SysMultivalues) object; return mv.getMvMeaning(); } public String getIdValue(Object object, int index) { if (index == -1) return null; return ((SysMultivalues)mvValues.get(index)).getMvCode(); } }); mvValues = sysMultivaluesProvider.getMVList(mvCode); } ... .. now I call this in the following way.. --- .... import net.databinder.valid.hib.ValidDataForm; @AuthorizeInstantiation(Roles.USER) public class updateUserProfile extends Panel{ private static final long serialVersionUID = 2834437668800017171L; EditForm form; ... public updateUserProfile(String id, String userId) { super(id); final Integer userIdInt = Integer.parseInt(userId); add(form = new EditForm("userProfileForm", Long.parseLong(userId.trim()))); } protected class EditForm extends ValidDataForm { @SuppressWarnings({ "serial", "unchecked" }) public EditForm(String id, Long userId) { super(id, SecUsers.class,userId); add(new TextField("userName").setRequired(true)); ..... add(new mvDropDownChoice("userProfile.country","COUNTRY", this.getModel())); ..... and this generates the following HTML output -- <select name="userProfile.country" class="select" wicket:id="userProfile.country"> <option selected="selected" value="">Choose One</option> <option value="ARG">Argentina</option> <option value="UY">Uruguay</option> </select> --- Wich is correct, O have the code.. as the value. the description as the user readable choice.. the CODE is persisted to the database (AKA in a select country from sec_users the country is returned ARG | UY and not Argentina | Uruguay which is what I need..) but my problem as stated before is that I can't get the choice to come up with the correct selected value (Argentina / Uruguay) and it always comes out with "Choose One".. TIA |
mvDropDownChoice.java
Description: Binary data
SysMultivalues.java
Description: Binary data
updateUserProfile.java
Description: Binary data
