I have an User class with a gender field using a Gender-Enum: public class User implements DomainObject<Long> { ... private Gender gender;
I want to bind this gender field to a radiogroup (representing all enum values) in a registration form. This is what I did so far: <code> public enum Gender { MALE, FEMALE }; public class RegistrationEntryPanel extends Panel { private User user = new User(); public RegistrationEntryPanel(String id) { super(id); // default value user.setGender(Gender.MALE); CompoundPropertyModel userModel = new CompoundPropertyModel(user); final RadioGroup<Gender> genderGroup = new RadioGroup<Gender>( "genderGroup", userModel.bind("gender")); Form form = new Form("form", userModel) { @Override protected void onSubmit() { System.out.println("USER: " + user); } }; add(form); form.add(genderGroup); // gender Gender[] genderValues = Gender.values(); List<Gender> genders = Arrays.asList(genderValues); ListView<Gender> genderList = new ListView<Gender>("genderList", genders) { @Override protected void populateItem(ListItem<Gender> item) { item.add(new Radio<Gender>("radio", item.getModel())); item.add(new Label("label", getString(item.getModelObject() .toString()))); } }; genderGroup.add(genderList); } } </code> This works so far: I can select a radio button and the value in the user object is changed on submit. But as I have to use different models for the group and the listview, the default setting with "user.setGender" has no effect. How can I preselect the first radio button of the listview or better the dedicated MALE radio button? --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org