I have a DropDownChoice which is returning null Ajax update, the model is passed as a List. Here is the code:
My intention, of course, is onUpdate, retreive the currently selected group.
final List<GbGroup> groups = this.businessService.getSiteSectionsAndGroups();
toolbar.add(new EmptyPanel("groupFilterOnlyOne").setVisible(false));
// add the default ALL group to the list
String allGroupsTitle = getString("groups.all");
groups.add(0, new GbGroup(null, allGroupsTitle, null, GbGroup.Type.ALL));
final DropDownChoice<GbGroup> groupFilter = new DropDownChoice<GbGroup>("groupFilter", new Model<GbGroup>(),
groups, new ChoiceRenderer<GbGroup>() {
private static final long serialVersionUID = 1L;
@Override
public Object getDisplayValue(final GbGroup g) {
return g.getTitle();
}
@Override
public String getIdValue(final GbGroup g, final int index) {
return g.getId();
}
});
groupFilter.add(new AjaxFormComponentUpdatingBehavior("onchange") {
@Override
protected void onUpdate(final AjaxRequestTarget target) {
final GbGroup selected = (GbGroup) groupFilter.getDefaultModelObject();
// store selected group (null ok)
final GradebookUiSettings settings = g_Page.getUiSettings();
settings.setGroupFilter(selected);
g_Page.setUiSettings(settings);
}
});