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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:14:44+00:00 2026-05-15T02:14:44+00:00

I have a Controller bean (SearchController) that has two managed bean as managed properties

  • 0

I have a Controller bean (SearchController) that has two managed bean as managed properties (SearchCriteria, SearchResults; both of which are session scoped).

When the user hits the find button, the action method that is executed is in SearchController.

The SearchCreteria managed bean has a method called search(). This method returns a new SearchResults object. In the controller bean, I am setting the searchResults managed property to be this new SearchResults object. The searchResults object contains what I expect during that request, but the object does not persist in the managed bean.

I understand that I am changing what object that searchResults is referencing, but what I don’t understand is why JSF isn’t updating the model to use the new object. Any ideas what I’m missing or don’t understand? I am using JSF 1.1 on WebSphere 6.1.

If I put the search method in the SearchResults managed bean, it works.

The line in SearchController.find() that is commented out is the one that presently works.

public class SearchController {

SearchCriteria searchCriteria;
SearchResults searchResults;
ResultsBacking resultsBacking;


public String find()
{

    setSearchResults(searchCriteria.search());
//      searchResults.findSearchResults(searchCriteria);

    if (!searchResults.resultsFound())
    {
        return "noresults";
    }

    return "success";
}


public class SearchCriteria {

public SearchResults search()
{
    SearchDAO sdao = new SearchDAO();
    ArrayList<Group> list = (ArrayList<Group>)sdao.findGroups(this); 

    SearchResults searchResults = new SearchResults();
    searchResults.setSearchResults(list);
    return searchResults;
}

}


public class SearchResults {

List<Group> searchResults;

public void findSearchResults(SearchCriteria criteria)
{
    SearchDAO sdao = new SearchDAO();   
    this.setSearchResults(sdao.findGroups(criteria));
}   
}
  • 1 1 Answer
  • 1 View
  • 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-15T02:14:45+00:00Added an answer on May 15, 2026 at 2:14 am

    In a nut, you’ve something like this:

    @ManagedBean
    public class SearchController {
    
        @ManagedProperty(value="#{searchCriteria}")
        private SearchCriteria searchCriteria;
    
        @ManagedProperty(value="#{searchResults}")
        private SearchResults searchResults;
    
        public void find() {
            searchResults = searchCriteria.search();
        }
    
    }
    

    And the #{searchResults} in the view doesn’t contain the desired results?

    This sounds like as if you’re accessing the search results by #{searchResults.someData} instead of #{searchController.searchResults.someData} and you’re expecting that overriding the SearchResults property inside the SearchController will replace the current session scoped managed bean.

    This is wrong.

    You need to solve it by either using #{searchController.searchResults.someData} instead

    <h:outputText value="#{searchController.searchResults.someData}" />
    

    Or by overriding (setting) the properties of SearchResults instead of overriding the whole managed property of SearchController:

        public void find() {
            searchResults.setSomeData(searchCriteria.search().getSomeData());
        }
    

    Or by manually replacing the bean in session (not recommended).

        public void find() {
            searchResults = searchCriteria.search();
            FacesContext.getCurrentInstance().getExternalContext()
                .getSessionMap().put("searchResults", searchResults);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a session scoped bean in my @Controller: it is called SessionPreferences and
I have a form bean defined in session scope and a controller bean defined
I have a controller that is stateless which takes care of processing forms. This
I have the following JSF2 controller / bb which i have injected a session
I have controller users . In this controller I have action account which is
Hi guys i have controller which returns a partial view, the controller is called
I'm using JSF 2.0 with GlassFish 3.0. I have the following Managed Bean: @ManagedBean
I have a Spring MVC Controller class (bean): @Controller @RequestMapping(/index.jsp) public class EjbCaller {
I have a controller that inherits from the org.springframework.web.servlet.mvc.AbstractController class I have configurated it
Currently I have only one controller AppController ( SessionScope - ManagedBean ) that handles

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.