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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:58:16+00:00 2026-06-01T15:58:16+00:00

I am using JSF and spring . I have a spring managed bean in

  • 0

I am using JSF and spring . I have a spring managed bean in session scope. I am getting a quite big list from a service call . I am calling the service and getting the list In the getter which is bind to the jsf view. when I run the app the getter is called multiple times.

so before the list is returned it is invoked again and it times out.

The list is dynamic I need to get fresh list on page load and every minute the list is refreshed using richfaces a4j poll . The list has to be retrived everytime from database.

If I change the bean to request scope and move the service call to the constructor the performance is worse.

can anyone suggest a better archetecture to do this ?

  • 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-01T15:58:17+00:00Added an answer on June 1, 2026 at 3:58 pm

    JSF managed bean getters should absolutely not call services. They should just return the managed bean property. This property should be already prepared by a (post)constructor or (action)listener method. Those methods will be invoked exactly one time. Getters will be invoked multiple times as JSF needs to access the value.

    You need to rewrite your code as such that the first-time job is done in the (post)constructor of the managed bean and that the <a4j:poll> invokes a listener method which refreshes the list and that the getter does absolutely nothing else than just returning the property.

    Here’s a basic kickoff example using the standard Java EE 6 artifacts. I don’t do Spring, but you should be able to supplant this with Spring artifacts.

    @ManagedBean
    @SessionScoped
    public class Bean {
    
        private List<Entity> entities;
    
        @EJB
        private EntityService service;
    
        @PostConstruct
        public void load() {
            entities = service.list();
        }
    
        public List<Entity> getEntities() {
            return entities;
        }
    
    }
    

    with

    <a4j:poll action="#{bean.load}" interval="60000" render="someTableId" />
    

    See also:

    • Why JSF calls getters multiple times

    Unrelated to the concrete problem: if you have a rather large DB table (>1000 rows) then copying the entire DB table into Java’s memory is a pretty bad idea. Implement pagination/filtering.

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

Sidebar

Related Questions

Im using websphere server and JSF 2.0 In my managed bean i have declared
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
Its been quite some time since i have started developing web pages using JSF
Problem Description: My injected Spring bean defined as a Managed-Property to a JSF backing
I have a session scoped managed bean with name 'usermanager'. i want to store
guys i'm using jsf 2.0 with spring. I have annotated a method in a
We are using JSF 2.0. We have to pass in view parameters from one
i'am using JSF and Spring in a web application. If the Spring Controller throws
I am developing a Java Web Application using JSF, Spring and Hibernate. I need
i am using spring 3 , JSF 2 , MYSQL , Hibernate , and

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.