1

I was designated as a developer to upgrade our old wicket app from 6.x to 8.x. I am resolving multiple errors one by one, but (since I never worked with wicket) one I am unable to move on with.

In version 6.x it had DropDownChoice with overriden onSelectionChanged which no longer exists in version 8.x and I am unable to find any info about deprecation (going through 7.x versions...) so it seems they just removed it .. what are my alternatives here? The aforementioned code:

booleanType = new DropDownChoice<BooleanType>("booleanType", new PropertyModel<>(this, "selectedBooleanType"), booleanTypes) {
            

            @Override
            protected void onSelectionChanged(BooleanType newSelection) {
                super.onSelectionChanged(newSelection);
                selectedBooleanType = newSelection;
            }
        };

EDIT: Similar question that I found only later Wicket 6 to 8 upgrade: RadioGroup.onSelectionChanged() replacement

for those wondering how to update the value since it is not coming as an argument of the method anymore:

                selectedType = (YourChoiceType) super.getFormComponent().getDefaultModelObject();
hocikto
  • 871
  • 1
  • 14
  • 29

1 Answers1

4

wantOnSelectionChangedNotifications moved to FormComponentUpdatingBehavior. From the changelog:

// Wicket 7.x
new CheckBox("id", model) {
    protected boolean wantOnSelectionChangedNotifications() {
        return true;
        }
 
    protected void onSelectionChanged(Boolean newSelection) {
        // do something, page will be rerendered;
    }
};
 
 
// Wicket 8.x
new CheckBox("id", model)
.add(new FormComponentUpdatingBehavior() {
    protected void onUpdate() {
        // do something, page will be rerendered;
    }
 
    protected void onError(RuntimeException ex) {
        super.onError(ex);
    }
});

(The example uses a CheckBox but it also applies to DropDownChoice).

For another example see the wiki.

Joachim Rohde
  • 5,915
  • 2
  • 29
  • 46
  • I looked at it before asking this question and just went on... I don't know. Must focus more. Thanks! One thing though - were there any @Deprecated annotations for this method in some version before removing it? Just to know if I should only refer to wiki or I'll be able to find some hints in the code directly when updating further. – hocikto Sep 16 '20 at 07:14
  • 2
    Just in case you didn't see them: the migration pages are quite complete. For 6 -> 7: https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+7.0 and for 7 -> 8: https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+8.0 I don't know if there have been any deprection annotations. – Joachim Rohde Sep 16 '20 at 07:22