问题描述
我需要编写一个自定义 ValueChangeHandler
并调用 onValueChange(ValueChangeEvent)
。但我不明白如何编写 ValueChangeEvent
。
编辑:我在问如何创建自己的派发ValueChangeEvent的类。我知道如何听它。
ValueChangeEvent的构造函数不可见,我无法创建它。
如果您想触发 一个简单的实现就是使用EventBus: 请注意,您需要替换 由于您无法直接创建ValueChangeEvent,因此通过fire方法调度事件: 其中 I need to write a custom Maybe I understand the entire GWT event system wrong. Can anyone help? Edit: I am asking how to create my own class that dispatches the ValueChangeEvent. I understand how to listen to it. The constructor of ValueChangeEvent is not visible and I can't create it. If you want to fire a A simple implementation would be to use the EventBus: Note you need to substitute Because you can't create a ValueChangeEvent directly dispatching an event is done via the fire method: Where 这篇关于自定义ValueChangeHandler GWT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! ValueChangeEvent
,您必须实现接口 HasValueChangeHandlers $ c $或者你的班级或班上的某个地方。
EventBus bus = new SimpleEventBus();
@Override
public void fireEvent(GwtEvent<?> event){
bus.fireEvent(event);
$ b @Override
public HandlerRegistration addValueChangeHandler(ValueChangeHandler< T>处理程序){
return bus.addHandler(ValueChangeEvent.getType(),handler);
T $ c
ValueChangeEvent.fire(this,value);
这个
指向类/字段实现 HasValueChangeHandlers
和值
指的是已更改的值,并且您想分派该事件。ValueChangeHandler
and call out onValueChange(ValueChangeEvent)
. However I don't understand how to write a ValueChangeEvent
.ValueChangeEvent
you must implement the interface HasValueChangeHandlers
by or your class or somewhere in the class. 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);
}
T
with the type you want to fire.ValueChangeEvent.fire(this, value);
this
refers to the class/field implementing the HasValueChangeHandlers
and value
refers to the value that has been changed and you want to dispatch the event.