Hi there,
I like Vaadin and I’m developing a little demo to know its features. My demo application has two layouts: A layout for the header and another one for the body. I would like to change the body layout without changing the state of the header one. It would be something like this:
public void init()
{
window = new Window("My Vaadin Application");
setMainWindow(window);
mainLayout = new VerticalLayout();
header=createHeader();
body=createBody();
mainLayout.addComponent(header);
mainLayout.setComponentAlignment(header,Alignment.MIDDLE_RIGHT);
mainLayout.addComponent(body);
getMainWindow().setContent(mainLayout);
}
[/code]
And when a button is pressed:
[code]
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
body=new DemoLayout());
}
}
[/code]
Is there any way to send this change to the client? I only want to refresh the body layout not the whole window. I’ve been trying to find a way to do it but no success.
Thanks in advance.
is there any other way to achieve this? Thing is, that in my application architecture I don’t know at the time of switching what exactly is the old “body”, my case (clutter omitted):
public class CustomerWindow extends MyWindow {
protected final VerticalLayout verticalMain;
protected Layout contentPanel;
protected void buildContentOrdersCreate() {
statusLabel.setCaption("Orders >> Create A New Order");
SplitPanel sp = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
contentPanel = sp;
}
protected void buildContentOrdersAll() {
statusLabel.setCaption("Orders >> View All Orders");
contentPanel = new SplitPanel();
}
and this is part of the code from my menubar:
menuCommand = new Command() {
public void menuSelected(MenuItem selectedItem) {
CustomerWindow cw = ((CustomerWindow) myWindow);
if (selectedItem == ordersAll) {
cw.buildContentOrdersAll();
} else if (selectedItem == ordersNew) {
cw.buildContentOrdersCreate();
}
}
};
problem is it doesn’t work this way… only by assigning a new Component to contentPanel it is not refreshed. Where to go from here?
EDIT: problem solved, my whole approach to content switching was wrong, now I reworked it from the ground, and this problem is no longer relevant