PDA

View Full Version : [CLOSED] Blue background after Viewport.removeAll



zaccret
30 May 2008, 2:02 AM
Env : Windows XP, gxt 1.0beta3, IE6, FF2/3
I have a centered login form (in a white background). When the user logins, I remove the form panel and build a new UI. When the user disconnects, I remove all the components and add the login panel again. But then, the background is blue...

public void onModuleLoad() {
final Viewport viewport = new Viewport();
viewport.setLayout(new CenterLayout());

final FormPanel formPanel = new FormPanel();
formPanel.setHeading("My panel");
formPanel.setWidth(400);

Button submitButton = new Button("Submit");
submitButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
viewport.removeAll();
viewport.setLayout(new BorderLayout());
ToolBar topPanel = new ToolBar();
TextToolItem tool1 = new TextToolItem("Go back");
tool1.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
viewport.removeAll();
viewport.setLayout(new CenterLayout());
viewport.add(formPanel);
viewport.layout(true);
}
});
topPanel.add(tool1);
viewport.add(topPanel, new BorderLayoutData(Style.LayoutRegion.NORTH, 25));
ContentPanel west = new ContentPanel();
west.setHeading("West");
viewport.add(west, new BorderLayoutData(Style.LayoutRegion.WEST, 200, 150, 350));
ContentPanel mainPanel = new ContentPanel();
viewport.add(mainPanel, new BorderLayoutData(Style.LayoutRegion.CENTER));
viewport.layout(true);
}
});
formPanel.addButton(submitButton);
viewport.add(formPanel);
RootPanel.get().add(viewport);
}

gslender
30 May 2008, 2:50 AM
You are not really destroying the formpanel. Do you have this problem if you actually set formpanel = null and re-create the object? you would need to change the formpanel from final to perhaps a global, but otherwise should be doable.

zaccret
30 May 2008, 3:02 AM
I think that after the first removeAll call (on click on submit button), formPanel shouldn't be referenced by the DOM.
Anyway, if I do

formPanel.destroy(); //on submit
...
viewport.add(new FormPanel()); //on go backinstead of adding the old formPanel (or even using global variable and set it to null), I have the same issue.

darrellmeyer
3 Jun 2008, 7:17 AM
BorderLayout adds a style to its container. When you "go back" that style remains. You can clear the style name if desired:


public void componentSelected(ToolBarEvent ce) {
viewport.removeAll();
viewport.setStyleName("");
viewport.setLayout(new CenterLayout());
viewport.add(formPanel);
viewport.layout();
}