Hey guys, I'm back to using Wicket after a 3 year break! Anyway, if any of you can help with this delightful pain I'd return the favor (eventually!).
Background: - I have a DTO/VO that has a property that is a list of strings (e.g. String[] propertyA) - The lookup items (choices) for this property is a list of name/value pairs (e.g. EnumerationValue class) and the values will be the ones that need to be passed onto the DTO/VO property. public class EnumerationValue implements Serializable { private String code; private String description; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } } I had setup a custom model to handle the translation between the collection of EnumerationValues coming from the UI and into the DTO/VO object: private IModel createFundInstrumentTypeCodeModel(final List<EnumerationValue> choices) { return new IModel<List<EnumerationValue>>() { // this gets the value from the model object backing the form public List<EnumerationValue> getObject() { final List<String> codes= wizard.getFundingInstrumentCodes (); // loop through the 'choices' and compare the code of each choice with the string list // pick out all the matching items from the choices return CollectionHelper.get(choices, codes); } // this sets the value from the form into the model object backing the form public void setObject(List<EnumerationValue> object) { // convert the list into a string list and set the DTO/VO wizard.setFundingInstrumentCodes(CollectionHelper.convertToStringList(object)); } public void detach() { } }; } This custom model was working fine when I was using CheckBoxMultipleChoice but I changed to CheckGroup since I wanted more control over the HTML being produced. CheckGroup doesn't call the setObject() everytime the form is submitted; accoridng to the updateModel() method, it only gets called when the backing model object is null. public void updateModel() { Collection collection = getModelObject(); if (collection == null) { collection = getConvertedInput(); setModelObject(collection); } else { modelChanging(); collection.clear(); collection.addAll(getConvertedInput()); setModelObject(collection); // TODO: Added this to allow conversion of list of enumerated values into list of strings modelChanged(); } } I've added the TODO line in there so that correct trnslation between list of strings and list of EnumerartionValue can occur. Am I doing this correctly or am I on the wrong ttrack. Thanks! Aye