You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kai Mütz <mu...@a3technology.de> on 2008/02/21 00:04:21 UTC

Problem while updating model within DojoDropDownChoice

Hello list,

I am new to wicket and playing around with the DojoDropDownChoice from
wicketstuff-dojo-1.3.0-beta. I want to use it similar to a "normal"
DropDownChoice component with ChoiceRenderer. But after selecting an entry
of the list and submiting the form the model is not updated correctly. The
corresponding ModelObject is set to null.

Has anybody experience in this issue? Can anybody help me? Is it possible to
use DojoDropDownChoice similar to a DropDownChoice within a form. Do I have
to use the DojoSubmitButton in this case? Which methods of
DojoDropDownChoice do I have to override exactly?


Example:

public final class MyModelChoiceRenderer implements IChoiceRenderer {

    public Object getDisplayValue(final Object object) {
        MyModel model = (MyModel) object;
        return model.getValue();
    }

    public String getIdValue(final Object object, final int index) {
        MyModel model = (MyModel) object;
        return String.valueOf(model.getId());
    }

}

public final class MyDropDownChoice extends DojoDropDownChoice {

    public MyDropDownChoice(final String id, final IModel model,
        final List< ? extends MyModel> data) {
        super(id, model, data, new MyModelChoiceRenderer());
        super.setHandleSelectionChange(true);
    }

}

List<MyModel> models = getModels();

form.add(new MyDropDownChoice("id", new PropertyModel(myObject, "myModel"),
models));
form.add(new MySubmitButton);



Where myObject is a field of type MyModel with corresponding getter/setter.
Any ideas?

Regards, Kai


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org