Don’t know about you but apache wickets DropDownChoice has always confused me somewhat. Take today, I was trying to createa simple dropdown choice that displays all the ‘cubes’ in our web application . It wasn’t tied to a form, as I had overrided the onSelectionChanged menthod. So we had:
add(new DropDownChoice<TeamProject>("otherCubes", getCubeService().getCubes()) {
@Override
protected boolean wantOnSelectionChangedNotifications() {
return true;
}
@Override
protected void onSelectionChanged(TeamProject newSelection) {
setResponsePage(new ProjectPage(newSelection));
}
});
This seem to work fine until I actually selected something. I was getting:
java.lang.IllegalStateException: Attempt to set model object on null model of component: cubeTab:cubesContainer:allProjects:otherCubes
at org.apache.wicket.Component.setDefaultModelObject(Component.java:3007)
at org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1141)
at org.apache.wicket.markup.html.form.DropDownChoice.onSelectionChanged(DropDownChoice.java:157)
at java.lang.reflect.Method.invoke(Unknown Source)
turns out I must have a default model, even if I don’t use it :
...
add(new DropDownChoice<TeamProject>("otherCubes", new Model(), getCubeService().getCubes())
..







0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.