Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6403

DropDownChoice ignores OnChangeAjaxBehavior while setting null value when required is true

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 8.0.0-M6
    • None
    • None
    • None

    Description

      I have a simple DropDown with OnChangeAjaxBehavior:

      List<String> choices = Arrays.asList("one", "two", "three");
      IModel<String> wicketModel = Model.of();
      DropDownChoice<String> wicketDropDown = new DropDownChoice<>("wicketDropDown",wicketModel , ListModel.of(choices));
      wicketDropDown.add(new OnChangeAjaxBehavior() {
      	@Override
      	protected void onUpdate(AjaxRequestTarget target) {
      		System.out.println("Wicket change: "+wicketModel.getObject());
      	}
      });
      add(wicketDropDown);
      

      onUpdate is called everytime I change the value even if this value is "null value".

      Now when instead of:

      add(wicketDropDown);
      

      I set:

      add(wicketDropDown.setRequired(true));
      

      onUpdate works on selecting values but does not work when selecting "null value" which is wrong.
      One of the use cases why it is wrong: I have two dropdowns. First dropdown selects Group and second selects Subgroup. Subgroup can not be selected if Group is null, though if I select Group, then I select Subgroup and then clear the Group - Subgroup should be cleared as well (but I'm not able to do that because onUpdate is not being called).

      Attachments

        Activity

          People

            svenmeier Sven Meier
            eximius Kamil
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: