Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7051513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:16:21+00:00 2026-05-28T03:16:21+00:00

I am developing an application with JSF and PrimeFaces. I have a managed been,

  • 0

I am developing an application with JSF and PrimeFaces.
I have a managed been, session scoped, that has username, password and isUserLoggedIn.
When I process a login component it works and changes my page accordingly. As soon as I move to another page I lose the data the username data. I need to access username during the entire application.
Does anyone know why I lose the data which should eb session scoped? why do I keep it from one page and not for the others?
Thanks

import authentication.AuthenticatorManagerLocal;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean
@SessionScoped
public class UserMB {
    @EJB
    private AuthenticatorManagerLocal authenticatorManager;

    /** Creates a new instance of UserMB */
    public UserMB() {
    }

    Boolean isUserLoggedIn;
    String username;
    String password;
    String nickName;

    public String getNickName() {
        nickName="vanessa";
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public Boolean getIsUserLoggedIn() {
        return isUserLoggedIn;
    }

    public void setIsUserLoggedIn(Boolean isUserLoggedIn) {
        this.isUserLoggedIn = isUserLoggedIn;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String authenticateUser(){
       isUserLoggedIn= authenticatorManager.authenticateUser(username, password);
       if(isUserLoggedIn)return "Home";
       else
           return null;
    }

    public void logout(){
        isUserLoggedIn=false;
        username="";
        password="";
    }

    public String goToIndex(){
        return "Index";
    }

}

HOME has

<p:commandButton value="SearchCB" action="#{expSearchResultsMB.search()}" ajax="false" />  

inside a custom component

expSearchResultsMB.search() sends to SearchResults
where I want to display the username

 <h:outputLabel value="#{userMB.username}" /> 

I need to access username and isUSerLoggedin in every page of the application.
When I check if the user is logged in I launch Home if he is.
Home shows the username correctly, but when from home I use searchCB the landing SearchResults page doesn’t show the username.

Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:16:22+00:00Added an answer on May 28, 2026 at 3:16 am
    import javax.enterprise.context.SessionScoped;
    

    You’ve imported the wrong annotation for the session scope. If you’re using JSF @ManagedBean, then you need to import the scopes from the javax.faces.bean package. The above is for CDI @Named only.

    So, fix it accordingly:

    import javax.faces.bean.SessionScoped;
    

    A @ManagedBean without the right scope would behave as @NoneScoped. I.e. a new instance will be created on every EL evaluation which is exactly the problematic behaviour you’re seeing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web application using JSF on Netbeans 7.0. I have created
I am developing an application in JSF 2.0 and I would like to have
I am developing a web application that uses JSF 1.2 for the view layer.
I'm developing a web application using Java EE6 and JSF 2.0. I have a
I'm developing a simple JSF application, but I'm stuck again... Basically, I have a
I am developing a Java enterprise application and I am usign JSF, mostly Primefaces.
we're developing an application using JSF 2.0 (primefaces) and Hibernate 3.6.1 We're following the
I'm developing a web application using Spring, JSF 2 and Primefaces 3. I want
I am developing a web application using JSF and JPA(Eclipse link). I have two
I'm developing an application in JSF 2.0. I'm also using the Primefaces component library.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.