1

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);

            }
        });
thg
  • 1,209
  • 1
  • 14
  • 26
Fer
  • 460
  • 2
  • 4
  • 17
  • When you initialize GbGroup do you set an id? or is it null? – atha Jul 27 '16 at 06:49
  • Hey @atha , what do you mean? it is the first line of code in the post. I am not sure what initialization you are referring to. – Fer Jul 27 '16 at 12:49
  • new GbGroup(null, allGroupsTitle, null, GbGroup.Type.ALL) is the first null the id for GbGroup? – atha Jul 27 '16 at 12:50
  • hello @atha I did not. I added one to it, same result, null onchange. I just saw the POST comindg from the browser, the value is null, so the backend is fine. I will check the markup since there are many wicket nested components within it – Fer Jul 27 '16 at 13:24
  • 1
    Try debugging 'org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.convertChoiceIdToChoice(String id)' to see why your choice is not converted into an object – atha Jul 27 '16 at 13:27
  • Thank you @atha for the follow up. I was creating components for a greater framework and the dropdown, happened to have the SAME name of a parent DOM one, hence the POST was empty (it was submitting the original's value) .. I did not have access to the parent components until now. What are the odds! - I still hate wicket though. – Fer Jul 27 '16 at 14:06

0 Answers0