Subwindow and notification

Hello! I want to show notification from sbwindow. I tried getWindow.getParentWindow.showNotification and getWindow.showNotification but have no effect. What I do wrong? How I can show notification?

What is exactly the problem? Do you get an error/exception?

You can try getApplication.getMainWindow().showNotification()

I have no notification window and no exceptions. getApplication.getMainWindow().showNotification() not work too

This is how i do it , it works perfectly for me :

	viewContent.getWindow().showNotification(
	                        "Window is already open");

viewContent is a VerticalLayout where my stuff is so i get the window of the VerticalLayout and show the notication in it .

if its not working post your code of how you add the subwindow

In my case, If I display a notification when I have a sub-window in the screen, notification is not disappearing.

I use vaadin 7, and I display the notification in the UI. Not in the sub-window.

How do you show the notification and the window? (Code snippets would help)

I just display window and notification with the following code.

getUI().addWindow(window);
.
.
Notification notification = new Notification("Logged out", Notification.Type.HUMANIZED_MESSAGE);
notification.setDelayMsec(15);
notification.show(Page.getCurrent());

I just created a small example like this: @Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); addWindow(new Window("test")); Button button = new Button("Click Me"); button.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Notification notification = new Notification("Logged out", Notification.Type.HUMANIZED_MESSAGE); notification.setDelayMsec(15); notification.show(Page.getCurrent()); } }); layout.addComponent(button); } When I then click on the button and move the mouse the Notification disappears almost immediately.
Is your setup different then the one in my sample?

Actually I used the window in my code as a login dialog box.

When I login,

  1. I just close the window and add the UI components which is the view of my site to an AbsoluteLayout.

When I logout.

  1. I use removeAllComponets() to remove all the components from the AbsoluteLayout.
  2. Adding back the login window to the UI. getUI().addWindow(window) 3. I display a notification says “Logged out”.

Notification notification = new Notification("Logged out", Notification.Type.HUMANIZED_MESSAGE); notification.setDelayMsec(15); notification.show(Page.getCurrent()); 4. Since it is a login dialog, I display notification for false credentials. I use the same code above to display that notification. And, It is disappearing immediately.
5.unfortunately, The “Logged out” message still stays and disappears only when I click it.

Could you create a small Example showing this problem which is strapped down to the minimal code needed to reproduce the issue? (Like my above example… with the difference that it shows the issue, of course)

I reproduced the same issue with this code. The strange thing is that this is not happening in 7.1.3. But, I use 7.0.5 in my project, and I can’t upgrade or downgrade to other versions. Try the code in 7.0.5. And I use Chrome.

public class HideNotificationUI extends UI {
	
	Window loginWindow;
	
	@Override
	protected void init(VaadinRequest request) {
		final VerticalLayout layout = new VerticalLayout();
		Button button = new Button("Click Me");
		button.addClickListener(new Button.ClickListener() {
			public void buttonClick(ClickEvent event) {
				layout.removeAllComponents();
				addWindow(loginWindow);
				notify("Logged out successfully.", Notification.Type.WARNING_MESSAGE, 15);
			}
		});
		layout.addComponent(button);
		setContent(layout);

        buildLoginDialog();
	}
	
	private void buildLoginDialog() {
		loginWindow = new Window("Log In");
		loginWindow.center();
		loginWindow.setHeight("30%");
		loginWindow.setWidth("15%");
		loginWindow.setClosable(false);
		loginWindow.setResizable(false);
		loginWindow.setDraggable(false);
		
		VerticalLayout loginWindowVContainer = new VerticalLayout();
		loginWindowVContainer.setSizeFull();
		loginWindowVContainer.setSpacing(true);
		loginWindowVContainer.addComponent(new TextField("User Id"));
		loginWindowVContainer.addComponent(new PasswordField("Password"));
		loginWindowVContainer.addComponent(new Button("Login"));
		loginWindow.setContent(loginWindowVContainer);
	}
	
	public void notify(String message, Notification.Type notificationType, int delayMsec) {
		Notification notification = new Notification(message, notificationType);
		notification.setDelayMsec(delayMsec);
		notification.show(Page.getCurrent());
	}
	
}

Hey Marius, Did you try my code? or Anyone else?

Hey Gugan.
Sry i didn’t have time last week to test your code. Now that i tried it i can confirm that this seems like a bug which causes the Notification delay not having an effect if a subwindow is open. If you close the window the notification will close as expected.
This bug is not present in the versions 7.1.0.beta1 and later.

Why can’t you update to a more current version? The only difference i can think of was that some add-ons suffered an issue where the behaviour of setParent was changed in 7.1 but i would hope that pretty much all Add-Ons managed to work around this issue by now.

Thank you Marius. But, I can’t close the window there. It is like a login dialog box.

I already tried updating the version. All my layouts changed and created a mess. I am afraid it may take a big amount of my time to modify it.

Anyway thanks for your time Marius. If you are interested can you please look in to
http://stackoverflow.com/questions/16216671/vaadin-disable-column-reordering-for-particular-column