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

  • Home
  • SEARCH
  • 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 3698796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:01:31+00:00 2026-05-19T05:01:31+00:00

I am running an application using JSF2.0 and Primefaces 2.2RC2 I have run the

  • 0

I am running an application using JSF2.0 and Primefaces 2.2RC2

I have run the profiler on my project and determined there was a bottleneck coming from a UISelectItems list. The list was being populated like 6 times on each action in my application.

The UISelectItem list was being populated in a getter method called getCountryList() and it looked like this

public UISelectItems getCountryList() throws Exception {
    Collection List = new ArrayList();
    List<Countries> c_list = myDao.getCountryList();

    for( QcardCountries c : c_list ) {
       list.add(new SelectItem(c.getCountryId().toString(), c.getCountryName());
    }

    UISelectItems countries = new UISelectItems();
    countries.setValue(list);
    return countries;
}

This works when I call in the views like so

<f:selectItems binding="#{myBean.countryList}" />

but again it is called like 6 times for each button or action I make in the application.

I then attempted to move the creation of the List into a method that was called on @PostContruct but when I do that the list does not show up when I use

 <f:selectItems binding="#{myBean.countryList}" /> 

It just shows up as empty. Does anyone know how to properly create a list so it is only created one time and can be called throughout an entire users session to populate a dropdown list?

  • 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-19T05:01:32+00:00Added an answer on May 19, 2026 at 5:01 am

    org.life.java already gave a hint about loading, but since you’re unnecessarily using binding and JSF 2.0 provides a way to just take List<SomeBean> instead of List<SelectItem> as value, here’s a complete example how to do it the right way:

    private List<Country> countries;
    
    @PostConstruct
    public void init() {
        countries = myDao.getCountryList();
    }
    
    public List<Country> getCountries() {
        return countries;
    }
    

    with

    <f:selectItems value="#{bean.countries}" var="country" itemValue="#{country.id}" itemLabel="#{country.name}" />
    

    (note that I renamed Countries model to Country and getCountryId() to getId() and getCountryName() to getName() since that makes more sense)

    See also:

    • Why JSF calls getters multiple times?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to generate sequence diagrams of a running java ee application using jtracert
I want to monitor my application running inside JBoss version 3.2.5 using JVisualVM. I
I've got an ASP.NET application running and on the production box it's using about
I've got a web application that is running against Windows Authentication using our Active
I got a webserver with a running application. There's a webpage with a form:
More particularly - I have a window handle of another running application. This application
How would I quit all running user applications using Applescript?
I've got a code that lists the running application on a win32 box, and
When running my application I sometimes get an error about too many files open
I am running an application through gdb and I want to set a breakpoint

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.