You should do it this way:
At first you'll need to create a class that implements
HasValueChangeHandlers interface. It is because of the fact that
ValueChangeEvent.fire() method requires a class that implements
HasValueChangeHandlers interface passed in a first parameter.
So let name that class MyHandlers (see below).
Then you should get an instance of MyHandlers class:
-----------------------
MyHandlers<String> exampleHandlers = new Handlers<String>();
-----------------------
and register ValueChangeHandler objects in that instance:
-----------------------
exampleHandlers.addValueChangeHandler(someHandler1);
exampleHandlers.addValueChangeHandler(someHandler2);
exampleHandlers.addValueChangeHandler(someHandler3);
-----------------------
Now you can fire ValueChangeEvent to all handlers that you've
registered in exampleHandlers object:
-----------------------
ValueChangeEvent.fire(exampleHandlers, "text");
-----------------------
MyHandlers class declaration:
-------------------------------------
public class MyHandlers<I> implements HasValueChangeHandlers<I> {
private final List<ValueChangeHandler<I>> list = new
ArrayList<ValueChangeHandler<I>>();
public void fireEvent(GwtEvent<?> event) {
if (event instanceof ValueChangeEvent) {
for (ValueChangeHandler<I> handler : list) {
handler.onValueChange((ValueChangeEvent<I>) event);
}
}
}
public HandlerRegistration addValueChangeHandler(final
ValueChangeHandler<I> handler) {
list.add(handler);
return new HandlerRegistration() {
public void removeHandler() {
list.remove(handler);
}
};
}
}
-------------------------------------
Hope that helps.
Best wishes!