How to Create SubWindows in Vaadin Applications
Today am going to show you how to Create SubWindows in Vaadin Web Applications.So lets think you are designing a web applications where users are required to Login to the Web Application using their username or email and Password.
Registered users should also be able to retrieve their password once they forget them.Such kind of application will require user to interact with different windows.For example,A window with TextField and PasswordField where he/she can enter details to login.Another Window where he can click to retrieve Password.Lets get down to coding and Create SubWindows.
Create SubWindows in Vaadin Applications
We can refer subwindows as child windows.Theses windows will be created and placed in the mainWindow which is created by the main Application method public void init().
This window is set as the mainWindow and other subwindows will be added usings addWindow() method.
Am going to introduced Public classes in this application.We are going to Create the Forgot Password window using public class.
Lets look at the code below
Above Code creates the MainWindow using the init() method that is executed once the application starts.After running the above code you should see this Window with Login Button
Once you click the Button,Login Window is created. There are several buttons in this window.Clear button uses setValue(“”) method to clear the text.This is how Login form should look like.
Create SubWindows Login
Create SubWindows Forgot Password
I have used Java classes to create this java subwindow.The class is in the same package as the main class.This code is executed once the forgot button is clicked.
Below is the code for creating forgot password window.
After Executing above code.Below Forgot password window opens up.