Hi sir ,
I have been creating one vaadin application . I have application class , Login window , Homewindow.
First i set login window as the mainwindow in application class. When user enter correct username and password , i changed the mainwindow as Homewindow.
What the problem here is that when i refresh the browser page the window automatically replaced by Login window . I have used auto refresher in my Homewindow .
I built an entire Vaadin app in a single file to show switching between two windows in Vaadin 6.7.6. I have one window for login, and another window for content.
Create a new Vaadin project, replace with this code, change the name of class and package at top, and run it. I added many calls to System.out.println to help see “beneath the covers”.
Not sure what you mean by “when i refresh the browser page”. Normally neither the programmer nor user wants to cause any refresh/reload of the browser page while running a Vaadin app. Perhaps you can clarify your situation.
I have used the Application.UserChangeListener as per your example code. You are correct that neither developer nor user don't want to refresh
the page while application is running . Actually Login window and Home window both are seperate class which extends window . I created the object
for that classes in Application class and set the mainWindow . Still the problem is while refreshing Home window is replaced by Login window.
Following code is used in my application.
[code]
//This is my login action in my LoginWindow class @Override
public void buttonClick(Button.ClickEvent event)
{
if(event.getSource() == btnlogin)
{
uname = txtusername.getValue().toString();
pword = txtpwd.getValue().toString();
try
{
BWLogin instance = BWLogin.getInstance ();
instance.authenticate((String)uname, (String)pword);
System.out.println( "DEBUG - User clicked Login button." );
event.getButton().getApplication().setUser( "anonymous user " + new java.util.Date() );
URL urL = BWLogin.getInstance ().getURL ();
open ( new ExternalResource (urL));
}
catch ( Exception e )
{
showNotification ( e.toString ());
}
}
}
// This is my logout action in the Application class
What do you mean by that phrase? Exactly what is the user or the computer doing?
Is the user hitting the web browser’s “Reload” or “Refresh” button to reload the entire web page?
Do you mean when the browser window redraws, such as when being revealed after some other window appeared on top?
Also, Nicolas Fränkel
suggests that there may be bugs or bad side-effects when switching the
Window in a Vaadin 6 app. He suggests keeping the single original Window, and then swap out the content of that Window. You can call the Window’s
setContent method to replace the current/default Layout in that Window. Or you can add and remove components to that current/default Layout.
Sir ,
You are correct that when user hitting the web browser’s"Reload" or “Refresh” button to reload the entire web page Home window replaced by Login window.
Now i have changed the code like what you said above . I have only one mainwindow and i changed the Login window and Home Window as customcomponents.(Not exends window)
I changed the view by using setContent method. But still when “Reload” or “Refresh” Home page is changed to Login page. I have one doubt also that I used autorefresher add on in
Home page .It Could cause this problem ? .