Actions and Handlers
Event handling methods
gwtXP generate code to register handlers to the widgets. The handler in turn will call appropriate Controller method for handling user’s actions. We name this method event handler or event handling method. Requirements for event handling method:
- Must be a public method
- Must have zero parameter or one parameter of type com.google.gwt.event.shared.GwtEvent
Examples for valid event handling method:
public void save(){
...
}
public void fetchRoles(){
...
}
Event name
Event name in gwtXP follows the GWT one. Table below list common event names.
| Handler | Event name | Description |
|---|---|---|
| ChangeHandler | onChange | Called when a change event is fired. |
| ClickHandler | onClick | Called when a native click event is fired. |
| KeyPressHandler | onKeyPress | Called when KeyPressEvent is fired. |
| ResizeHandler | onResize | Fired when the widget is resized. |
| SelectionHandler | onSelection | Called when SelectionEvent is fired. | ValueChangeHandler | onValueChange | Called when ValueChangeEvent is fired. |
Please note: this table is adopted from GWT EventHandler API document.
Setup event handler
In gwtxp.xml file, we can define event handler as below:
<button onClick="#{fetchRoles}" />
References
See References for complete document of widget properties and event names.


