Answer the question
In order to leave comments, you need to log in
Button handler on GWT?
Essence: there is a widget (panel). It has a button on it. When I click on a button, I want to remove the current widget entirely and go to another one.
Now I have a button
Button editBtn = new Button("Edit user",new editHandler(this));
private class editHandler implements ClickHandler {
private Widget panel;
editHandler(Widget panel) {
this.panel = panel;
}
public void onClick(ClickEvent event) {
isUserEditing = true;
RootPanel.get().remove(panel);
RootPanel.get().remove(panel);
RootPanel.get().add(new UserForm(resTab.selectedUser));
}
}
Button addUserBtn = new Button("Add user", new ClickHandler(this) {
.......
});
Answer the question
In order to leave comments, you need to log in
You will not be able to pass a button inside a handler like this.
Simply because ClickHandler will be created first (because it is a calculated value) and only then its instance will be passed to the Button constructor. By the time ClickHandler is created, your button constructor has not yet been called and there is no reference to it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question