Reputation: 3587
I am gwt2.3 with uibinder.In My application I am made a button and want to add a click handler bu using @UiHandler annotaion.Below is my code: ui.xml
<g:HTMLPanel>
<g:VerticalPanel>
<g:HorizontalPanel >
<g:Button ui:field="btnAccessLevel" text="Access Level" styleName="submit" />
<g:Button ui:field="btnSave" text="Save" styleName= "submit" />
</g:HorizontalPanel>
<g:AbsolutePanel ui:field="formPanel">
</g:AbsolutePanel>
<g:AbsolutePanel ui:field="accessLevelPanel">
</g:AbsolutePanel>
</g:VerticalPanel>
</g:HTMLPanel>
.java
@UiField
Button btnAccessLevel;
@Inject
public DocumentFormView(final Binder binder) {
widget = binder.createAndBindUi(this);
@UiHandler("btnAccessLevel")
void handleClick(ClickEvent e) {
Window.alert("Hello, AJAX");
}
}
When I am trying this I am getting this error: void is an invalid type for the variable handleClick I am not getting what issue is.Please help me out. Thanks in advance.
Upvotes: 0
Views: 2911
Reputation: 20890
Your code is not legal Java - move the function declaration outside of the constructor.
Otherwise, your syntax for @UiHandler is correct!
Upvotes: 2