Question

Can anybody tell me, why this source

List<Data> datas = ~getData();
PropertyListView<Data> listView = 
new PropertyListView<Data>("listView", new PropertyModel<List<Data>>(this, "datas")){

    private static final long serialVersionUID = 1L;

    @Override
    protected void populateItem(final ListItem<Data> item) {
        Data data = item.getModelObject();
        item.add(new MultiLineLabel("textLabel", data.getText());

        @SuppressWarnings("unchecked")
        ArrayList<DataParam> params = (ArrayList<DataParam>) ~getParamsForData(data);

        DropDownChoice<DataParam> dropDownChoice = 
            new DropDownChoice<DataParam>("choiceSelector", new Model<ArrayList<DataParam>>(params), new ChoiceRenderer<Object>("key", "value")){
            private static final long serialVersionUID = 1L;

            @Override
            protected boolean wantOnSelectionChangedNotifications(){
                return true;
            }

            @Override
            protected void onSelectionChanged(DataParam newSelection) {
                super.onSelectionChanged(newSelection);
            }

        };
        item.add(dropDownChoice);                   

    }
};


public static final class DataParam implements Serializable{
    private String key;
    private String value;
    public DataParam(String key, String value){ this.key=key; this.value=value;}
    public String getKey() { return key; }
    public void setKey(String key) { this.key = key; }
    public String getValue() { return value; }
    public void setValue(String value) { this.value = value; }
}

throws this exception

WicketMessage: No get method defined for class: 
class Data expression: choiceSelector
Root cause:
org.apache.wicket.WicketRuntimeException: 
No get method defined for class: class Data expression: choiceSelector

? (so looking for get method for choiceSelector wicket component id in Data class ?!) i don't even understand

Was it helpful?

Solution

Wicket is looking for a Model to read from and store to the selection made by the user (as well as the initially selected value).

Since you are using the DDC constructor without a model, wicket is looking in the parent of the DDC (the item) for an CompoundPropertyModel and uses the wicket:id of the DDC as expression. Hence you get the 'choiceSelectecor'.

You will either have to use an wicket:id to math the structure of your Data class or construct a DDC with a model for this.

Bert

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top