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 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 have developed a Phone Gap application using this link . Application is running
I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it
I am using Struts application while running welcome page is run successfully after that
I am running my delphi application using 'run as admin..' by right clicking on
Let's say I have an facebook application running using the JS SDK. First user
I have a java application running on linux machine. I run the java application
I am running a server application using JVM sunjava-1.6.0_21 . My application is data
I am currently running a simple EJB application using a stateless Session Bean. I
I am developing an MVC application using nHibernate; running through VS's built in web
I'm building a javascript application using object oriented techniques and I'm running into a

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.