Hi Vaadin!
I try to call a subwindow (depending on your book of vaadin, chapter 6.7) with this code:
removeSubjectButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Object nextId = subjectUiTable.nextItemId(subjectUiTable.getValue());
if (nextId != null) {
subjectBeanContainer.removeItem(subjectBeanContainer.getItem(subjectUiTable.getValue()).getBean());
subjectUiTable.setValue(nextId);
} else {
MessageWindow messageWindow = new MessageWindow();
messageWindow.setMessage("B Message");
messageWindow.setVisibility(Boolean.TRUE);
UI.getCurrent().addWindow(messageWindow);
}
}
});
where MessageWindow inherits from window. So this window shows fine, if i call it from the init method, but if i execute
this shown snippet by clicking the button, the window shows up emty on the left top edge of the browser window, nontheless it
should be placed centered with a textlabel and a button, the messageWIndow is:
public class MessageWindow extends Window {
private final Label messageLabel = new Label();
public MessageWindow() {
super("Message");
this.center();
this.setModal(true);
this.setEnabled(true);
this.setHeight("150px");
this.setWidth("150px");
// Some basic content for the window
VerticalLayout content = new VerticalLayout();
content.addComponent(messageLabel);
content.setMargin(true);
// Disable the close button
setClosable(true);
// Trivial logic for closing the sub-window
Button ok = new Button("OK");
ok.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
close(); // Close the sub-window
}
});
content.addComponent(ok);
this.setContent(content);
this.setVisible(false);
}
public void setVisibility(Boolean b) {
this.setVisible(b);
}
public void setMessage(String message) {
messageLabel.setValue(message);
}
}
most of the code is taken from vaadin examples.
It’s run inside an embedded jetty as a vaadin servlet.
Any help would be great, cuzi’m fumblin around with this for quite some while now
Regards Peter