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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:12:52+00:00 2026-05-26T08:12:52+00:00

I have my JSF Handler defined in request scope as follows public class JsfHandler

  • 0

I have my JSF Handler defined in request scope as follows

public class JsfHandler {
  private List<ManagedBean>  managedBeanList;   // managed bean List in session scope
}

    <managed-bean>
        <managed-bean-name>jsfHandler</managed-bean-name>
        <managed-bean-class>com.test.JsfHandler</managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>managedBeanList</property-name>
            <value>#{managedBeanList}</value>
        </managed-property>
      </managed-bean>

I have a session scoped JSF managed bean list in JSF defined as follows.

   <managed-bean>
      <managed-bean-name>managedBeanList</managed-bean-name>
      <managed-bean-class>java.util.ArrayList</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
   </managed-bean>

Approach 1:

managedBeanList.clear();
managedBeanList.addAll(service.getResultList());  
// assuming service.getResultList() would return a new ArrayList();

Approach 2:

managedBeanList =  service.getResultList();
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("managedBeanList",managedBeanList);

We are currently using approach 1.

Is approach 2 correct? Is there is any advantage in terms of memory usage when Java Garabage collector is called in appraoch 2.

  • 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-26T08:12:53+00:00Added an answer on May 26, 2026 at 8:12 am

    Neither is correct. That list has to be a property of a session scoped managed bean. You should avoid manually fiddling with the session map as much as possible.

    Neither of the one is more “GC-friendly” than the other. In approach 1 you end up with an unreferenced instance to the list as returned by service.getResultList(). In approach 2 you end up with an unreferenced instance of the list which was previously referenced by managedBeanList. In both cases the GC has to do the same job: cleaning an unreferenced instance.

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

Sidebar

Related Questions

I have a selectMenu, with list of (SelectItems) defined in handler as follows Handler
I am wondering if it is possible to have a JSF handler and some
Im using websphere server and JSF 2.0 In my managed bean i have declared
I tried simply: public class UIDemoComponent extends UIComponentBase { private String someVariable; // this
I have JSF code like: <h:inputText id=from value=#{fromToMBean.fromName}/> I would like to get this
I have a JSF application that uses mostly Richfaces. I would like to introduce
I have a JSF web client and a Java client that both use the
i have a JSF web application. I use Beans as Spring Beans (not JSF
I have a JSF application with several major components and a component tree under
I have two JSF <h:selectOneMenu> components. One called category another is subcategory . If

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.