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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:31:41+00:00 2026-05-16T20:31:41+00:00

I want to implement something like this using JSF.(part of search screen) More and

  • 0

I want to implement something like this using JSF.(part of search screen)alt text

More and more new rows will be added dynamically onclick of “+” button and the row will be removed on click of “–” button. The question is about binding the values (user input in those dynamically created rows) to the backing model.

I have created a session scoped backing bean. Some portions of the code,

public class BackingBean{
  //other code

  private List<Criteria> searchFilters; // Each criteria is bound to a row

  public void init(){
   //init code
  }
  public void addEmptyCriteria(){
    searchFilters.add(MyFactory.createNewCriteria());
  }

}

Action of + button triggers addEmtpyCriteria method and rerenders(using a4j) the entire section(with new rows).

This is just a boilerplate and everything works fine as long as the bean is session scoped. But its more intuitive to have it in request scope. A single search is a single request made by the user and in no way is tied to the user session. Also having it in session,forces the developer to clear/remove the backingbean from session inorder to display a fresh search screen.

Is there a better way of doing this? Is it right to have it in session scope ?

  • 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-16T20:31:41+00:00Added an answer on May 16, 2026 at 8:31 pm

    When you’re on JSF 2.0, then you can just put the bean in the view scope.

    @ManagedBean
    @ViewScoped
    public class BackingBean {
        // ...
    }
    

    When you’re still on JSF 1.x, then your best bet is using a4j:keepAlive. Make your bean request scoped and add the following to the JSF page:

    <a4j:keepAlive beanName="managedBeanName" />
    

    If you wasn’t using Ajax4jsf, then I would have suggested Tomahawk’s t:saveState. It does basically the same.

    <t:saveState value="#{managedBeanName}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement something like Col3 = Col2 + Col1 in SQL. This
I want to do something like this: I tried to implement it by myself
I want to implement something exactly like Changing the Default Text in the Search
I want to implement something like a WCF OData provider but using NetTcpBinding instead
I am learning OOP with python. I want to implement something like to display:
I want to implement something simple like /System/Workflows/Sample Workflow with the small addition of
i want to implement a dynamic relation mechanism with python something like: a:=10 b:=30
for iOS 5.0 using ARC, here is something I want to implement and need
I want to do something like this: public static TResult MyCast<TSource, TResult>(TSource item) {
I have a workflow that I want to looks something like this: / Worker

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.