In my project, for business reasons, we have classes with SortedSet members. 
The classes and their elements are all Serializable.  I'm having trouble 
working with a SortedSet<MantechControl> object; when I try creating a 
ListMultipleChoice<MantechControl> object for it (and putting it into a 
FormComponentPanel<SortedSet<MantechControl>>), I get all sorts of compilation 
problems.  The MantechControlPanel has constructor:

   public MantechControlPanel(String id,
            IModel<SortedSet<MantechControl>> model) {
        super(id, model);
        control = new ListMultipleChoice<MantechControl>(
                "choices", new SetModel<NonICDisseminationControl>(choices),
                choiceList, new ChoiceRenderer<MantechControl>(

The onModelChanged() method has (after I extracted some local objects in a 
futile attempt to fix things):

    protected void onModelChanged() {
        if (getModelObject()!= null) {

The problem is that the control.setModel() expects a Model of a Collection, 
while getModel() returns a  Model of a SortedSet:

    The method setModel(IModel<Collection< MantechControl >>) in the type 
FormComponent<Collection< MantechControl >> is not applicable for the arguments 
(IModel<SortedSet< MantechControl >>). I have good business reasons to use a 
sorted set, and what I think are good reasons to use a FormComponentPanel and a 
ListMultipleChoice. But should I do something different?

Meanwhile, I've created a wicket/metagen quickstart project and am running into 
a similar problem  there.  I can upload the project somewhere if you want more 
info.  Here I wrote a class ColorfulPerson that has a String name and a 
SortedSet<Color> colors.  In trying to write a FormComponentPanel for this, I 
have an obvious error at the indicated line:

public class ColorfulPersonPanel extends FormComponentPanel<ColorfulPerson> {
private static final long serialVersionUID = -457616015428125432L;
private final FormComponent<String> name;
private final FormComponent<Collection<Color>> colors;
private List<Color> colorChoices = Arrays.asList(Color.values());
public ColorfulPersonPanel(String id, IModel<ColorfulPerson> model) {
                super(id, model);
                name = new TextField<String>("name", new Model<String>());
                colors = new ListMultipleChoice<Color>("colors", new 
SetModel<Color>(), colorChoices);
protected void onModelChanged() {
                ColorfulPerson colorfulPerson = getModelObject();
                if (colorfulPerson != null) {
                                // Error as the model is one of 
SortedSet<Color> while the ListMultipleChioice expects a model of 

                } else {

Could there be a<?> castingClass) method?

Eric Jablow

This communication, along with any attachments, is covered by federal and state 
law governing electronic communications and may contain company proprietary and 
legally privileged information.  If the reader of this message is not the 
intended recipient, you are hereby notified that any dissemination, 
distribution, use or copying of this message is strictly prohibited.  If you 
have received this in error, please reply immediately to the sender and delete 
this message.  Thank you.

Reply via email to