Adding functionality to wicket palette button

326 Views Asked by At

I want to add some functionality to the right arrow button, the one that puts the user selection into the selected elements panel. Specifically, when the user selects an element from the avaliable choices, I don't want the element to be taken to the selected elements panel if there are elements at the right panel of another palette. So basically, what I need is to execute custom java code when the button is pressed, and alter the default behavior of the palette when a condition occurs.

1

There are 1 best solutions below

0
On

I found the solution somewhere else. Just in case someone needs it, here is what you have to do.

myPalette = new Palette<MyClass>(...) {
    @Override
    protected Recorder newRecorderComponent() {
        Recorder<MyClass> recorder = super.newRecorderComponent();     
        recorder.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                    protected void onUpdate(AjaxRequestTarget target) {
                        // Custom code
                        ...

                        if (target != null)
                            // Update another component
                            target.add(anotherComponent);
                    }
              }
        );
        return recorder;
    }
};