0

I am working on a JSF 2.0 application. I created a SessionScoped managed bean which stores some key data about the logged in user. When two different users login from two different machines, the user information stored in session bean by the first login user is overridden by the second user information. The following is the source code.

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;


@ManagedBean(name = "sessionBean")
@SessionScoped
public class SessionManagedBean implements Serializable
{

private static final long serialVersionUID = 1L;
private SetUsers user;


public String getUsername()
{
    if (user != null)
        return user.getUsrFirstname() + " " + user.getUsrLastname();
    return "";
}

public String getUserid()
{
    if (user != null)
        return user.getUsrLoginId();
    return "";
}

public int getUserGroup()
{
    if (user != null)
        return user.getUsrGroupId();
    return 0;
}



/**
 * @return the user
 */
public SetUsers getUser()
{
    return user;
}

/**
 * @param user
 * Set the user object
 */
public void setUser(SetUsers user)
{
    this.user = user;
}
}

How to maintain the user specific information so that it will not be affected multiple user login?

Thanks for any assistance.

4

0 回答 0