Java – custom valuechangehandler GWT
I need to write a custom valuechangehandler and call onvaluechange (valuechangeevent) But I don't understand how to write valuechangeevent
Maybe I understand the whole GWT event system is wrong Can I help you?
Editor: I asked how to create my own class for scheduling valuechangeevent I understand how to listen to it
The constructor of valuechangeevent is not visible and I cannot create it
Solution
If you want to fire valuechangeevent, you must implement the interface hasvaluechangehandlers through or class or somewhere in the class
A simple implementation is to use eventbus:
EventBus bus = new SimpleEventBus(); @Override public void fireEvent(GwtEvent<?> event) { bus.fireEvent(event); } @Override public HandlerRegistration addValueChangeHandler(ValueChangeHandler<T> handler) { return bus.addHandler(ValueChangeEvent.getType(),handler); }
Note that you need to replace T with the type you want to trigger
Because you cannot create valuechangeevent, the direct scheduling event is completed through the fire method:
ValueChangeEvent.fire(this,value);
This refers to the class / field that implements hasvaluechangehandlers, value refers to the changed value, and you want to schedule the event