Search code examples
textboxonchangezk

How to fire onChange event on ZK Textbox?


In ZK, say I have a Textbox

<textbox id="tb"/>

And then in java I do

private Textbox tb;
tb.setValue("some new value");

I want that when I set this value, to trigger the onChange (or onOK) method of the textbox, as if the user has inputed the new text himself and pressed enter.


Solution

  • In the java you just have to do:

    private Textbox tb;
    tb.setValue("some new value");
    Events.postEvent("onChange", tb, null);
    

    Check this to more information.