I have created a custom widget in GWT like:
public class Header extends Composite {
private Button btnContribute;
public Header() {
btnContribute = new Button("Contribute");
}
} //This is only a sample - in actual there are few bundled widgets
In my Entry point class I have used this custom widget as a north panel for my dockLayoutPanel as shown:
public class MyClass implements EntryPoint {
private DockLayoutPanel dockLayoutPanel;
private ScrollPanel contentScrollPanel;
private Header header; //My custom widget
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
dockLayoutPanel = new DockLayoutPanel(Unit.EM);
rootPanel.add(dockLayoutPanel, 20, 10);
header = new Header();
dockLayoutPanel.addNorth(header, 7.7);
dockLayoutPanel.addSouth(new HTML("south"), 7.7);
dockLayoutPanel.addWest(new HTML("west"), 7.7);
contentScrollPanel = new ScrollPanel();
dockLayoutPanel.add(contentScrollPanel);
htmlContent = new HTML("content", true);
contentScrollPanel.setWidget(htmlContent);
htmlContent.setSize("100%", "100%");
}
}
I want to create a onClick event handler on the button in my custom widget ‘btnContribute’ such that it dynamically updates the ‘contentScrollPanel’, deletes the current content, and say loads a form in it.
The problem is that I when I try to create a event handler in my custom widget, I am unable to figure out as to how should I add and remove widgets from my entry point class..
Create getter in
Headerclass ;In your
Entrypointclass add the handler like below :