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 7942299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:55:48+00:00 2026-06-03T23:55:48+00:00

Trying to add a functionality to our JSF 2 application to list active users

  • 0

Trying to add a functionality to our JSF 2 application to list active users (who have an active session) and for this I decided to use an application scoped managed bean and store the list of users, adding each by the time of a successful login. Then I would access the active user list (stored on the application scoped managed bean) from a jsf page – only if I could figure out how to resolve the following problem:

The application scoped bean : AppBean.java

@ManagedBean(name = "appBean")
@ApplicationScoped
public class AppBean implements java.io.Serializable {

    private List<User> connectedUsers = new ArrayList<User>();

    public AppBean() {
    }

    public List<User> getConnectedUsers() {
        return connectedUsers;
    }

    public void setConnectedUsers(List<User> connectedUsers) {
        this.connectedUsers = connectedUsers;
    }  
}

the Login Bean:

@Named(value = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {

    @ManagedProperty("#{appBean}")
    private AppBean appBean;

    private User userInSession;

    public LoginBean() {
    }

    public String authenticate() {
        if (this.authClearsOut()) {
            if (appBean != null)
                appBean.getConnectedUsers().add(userInSession);
            else System.out.println("appBean = null !!!!");
            return "/next_screen.xhtml?redirect=true";
        }
        else return "/login.xhtml?authentication=failed";
    }

    public AppBean getAppBean() {
        return appBean;
    }

    public void setAppBean(AppBean appBean) {
        this.appBean = appBean;
    }
}

Now there are two problems here:
1) the appBean is null unless I change line 6 of the LoginBean.java to private AppBean appBean = new AppBean();
2) User userinSession is never added to (List) connectedUsers.

What’s wrong here?

  • 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-06-03T23:55:50+00:00Added an answer on June 3, 2026 at 11:55 pm

    The JSF @ManagedProperty annotation works in JSF @ManagedBean only, not in CDI @Named.

    Change the LoginBean to be managed by JSF @ManagedBean instead, or change the AppBean beans to be managed by CDI @Named and then use @Inject instead of @ManagedProperty.

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

Sidebar

Related Questions

I have a very special scenario, and I'm trying to add functionality to list...
I am trying to add OpenSearch functionality to my Yii application and have trouble
I'm trying to add some basic file-download functionality to my Rails application and have
We're trying to add search functionality to our application. The search will be over
I am trying to add the functionality of adding jquery into an application. I
I have a question about some functionality I'm trying to add to my jQuery
I'm trying to add some functionality to our code base by using tied scalars.
I'm currently trying to add some testing functionality into our builds, and in order
I'm trying to add functionality to the Arrays-class. In my project I use the
I'm trying to add the functionality to this dynamic order form that will auto

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.