Reputation: 159
I'm new to Vaadin and am still learning. Here I am trying to get a basic Vaadin project to compile. I want it to and display a modal window when the UI runs, but am having trouble. Here is what I have so far:
CaptchaUI.java -
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;
public abstract class CaptchaUI extends UI {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
protected void init(VaadinRequest request) {
addWindow(new CaptchaWindow());
}
}
CaptchaWindow.java -
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
public class CaptchaWindow extends Window {
/**
*
*/
private static final long serialVersionUID = 1L;
public CaptchaWindow() {
// Some other UI content
setContent(new Label("Here's my UI"));
// Create a sub-window and set the content
Window subWindow = new Window("Sub Window");
VerticalLayout subContent = new VerticalLayout();
subContent.setMargin(true);
subWindow.setContent(subContent);
// Put some components in it
subContent.addComponent(new Label("Label"));
subContent.addComponent(new Button("Button"));
// Center it in the browser window
subWindow.center();
// Open it in the UI
addWindow(subWindow);
}
}
Could someone give me some help or recommendation to get it to display?
Thanks so much.
Upvotes: 2
Views: 3036
Reputation: 2749
According to Vaadin docs it is just as easy as setting
setModal(true)
on the sub window to make it modal.
Please note that the modal feature of Vaadin is just a client side restriction. Modifying the HTML with debug tools in the browser could still make it possible to click buttons in the background.
Upvotes: 3