I have a widget written in GWT. In the implementation of EntryPoint
, I have the widget load a controller and a view that is tied to that controller. I add this view to the RootPanel and it works fine.
public class EntryImpl implements EntryPoint {
SimplePanel simplePanel;
View view;
Controller controller;
public final void onModuleLoad()
{
controller = createController();
view = createViewForController(controller);
simplePanel = new SimplePanel();
simplePanel.add(view);
RootPanel.get().add(simplePanel);
}
}
Something like above. Now I want to change the view and controller, say if the user clicks a button to load a different view. I tried something along the lines of adding an Anchor and handling the ClickEvent as follows:
public void onClick(Widget sender) {
simplePanel.remove(view);
controller = createController();
view = createViewForController(controller);
panel.add(view);
}
Is this the right way to go about doing this, or is there a better way? So far, this isn't working for me-- my new view is not showing up.
Thanks