How to close (remove) Vaadin Modal Window by pressing a button


Friends the following udemy course created by me;

      Click here to attend Spring Framework 4.x and certification course with a discount

Spring Framework and Core Spring Certification Udemy course with discount
Spring Framework and Core Spring Certification Udemy course with a discount coupon

If you want to remove or close a modal window after pressing a button inside the Vaadin Modal Window, use the following code snippets;

1.solution is;

@Override
public void buttonClick(ClickEvent event) {
	Button source = event.getButton();
        if (source == send) { 
	    getApplication().getMainWindow().showNotification("Send Button Pressed");
	    getApplication().getMainWindow().removeWindow(getWindow());
	} else if (source == cancel){
	    getApplication().getMainWindow().showNotification("Cancel Button Pressed");
	} 
}

2.solution is;

@Override
public void buttonClick(ClickEvent event) {
	Button source = event.getButton();
        if (source == send) { 
	    getApplication().getMainWindow().showNotification("Send Button Pressed");
            //first access the parent window and remove the current window
	    ((Window) getWindow().getParent()).removeWindow(getWindow());
	} else if (source == cancel){
	    getApplication().getMainWindow().showNotification("Cancel Button Pressed");
	} 
}
Advertisements

One thought on “How to close (remove) Vaadin Modal Window by pressing a button

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s