Add fucntion call to WicketStuff Spinner properties

28 views Asked by At

How do you put a function call to the java.util.Properties' onIncrement, onDecrement, afterUpdate or onStop property of WicketStuff's Spinner configure method? I tried the following but the function is not called:

TextField<String> textField = new TextField<String>("textField ", new Model<String>("0"));
textField.add(new Spinner() {
    @Override
    protected void configure(Properties p) {
        super.configure(p);
        p.put("afterUpdate", "foo()");
    }
});

void fun() {
    System.out.println("Hello world!");
}

The Javadoc for these properties is:

onIncrement Function to call after incrementing
onDecrement Function to call after decrementing
afterUpdate Function to call after update of the value
onStop Function to call on click or mouseup (default=false)

Note that when setting other properties everything works fine.

1

There are 1 answers

0
martin-g On

Looking at https://github.com/wicketstuff/core/blob/034ab2b1363d1f81609fec8362d8a80beb163227/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/spinner/Spinner.java#L164-L192 I don't see how this could work. It iterates over the values from the Properties and checks their type. The else clause is what should cover your case. But the problem is that java.util.Properties can hold only String keys and values, so it will always go in the if clause, never in the else if and the else.

This code needs some improvements! Feel free to create an issue and send a Pull Request!