Search code examples
javajavascriptwicketdropdownchoice

How to add "onchange" SimpleAttributeModifier to DropDownChoice in Apache Wicket


I want to run a particular javascript when selection is changed in the drop down choice, so I added a simple attribute modifier like this :

ddc.add(new SimpleAttributeModifier("onchange", "calc();"));

But if I do this, it completely overrides the wicket onSelectionChanged() method. I need a way to perform both.

Thanks


Solution

  • You could use an AttributeAppender

    ddc.add(new AttributeAppender("onchange", "calc();", " "));
    

    The last argument is the separator used.