Composite
GWT でウィジェットを作成していますが、コンポジットの要素が選択されHasSelectionHander
たときにウィジェットを実装して起動したいと考えています。SelectionEvent
これまでのところ、私は次のものを持っています:
public class SelectionClass extends Composite implements HasSelectionHandlers<Integer>{
private final EventBus eventBus = new SimpleEventBus();
//...
private void somethingHappens(int i){
//How do i fire an event?
}
@Override
public HandlerRegistration addSelectionHandler(SelectionHandler<Integer> handler) {
return eventBus.addHandler(SelectionEvent.getType(), handler);
}
}
public AnotherClass{
// ...
SelectionClass.addSelectionHandler(new SelectionHandler<Integer>() {
@Override
public void onSelection(SelectionEvent<Integer> event) {
Window.alert(String.valueOf(event.getSelectedItem()));
}
});
// ...
}
イベントの発生を正確に実装する方法について少し混乱しています。EventBus
SelectionClass (上記) でを使用する権利はありますか? どんな助けでも大歓迎です。