0 Replies Latest reply on Mar 25, 2009 12:03 PM by Amit Srivastava

    Different instances of bean in the same request

    Amit Srivastava Newbie

      I have a newbie problem.


      I am invoking a method (doExperimentalSearch) in a bean (search) from a form. After the method call completes the result (like resultCount) is displayed in a xhtml (searchResults.xhtml). Now my problem is that search.getResultCount() is getting called on a different object than the search.doExperimentalSearch() and all my searchResults are getting lost. Please help.



      <h:form id="searchParams" name="searchParams" style="margin: 0; padding: 0;">
        <h:inputHidden id="searchType" value="#{search.selectedSearchType}"/>
        <h:inputHidden id="factorId" value="#{cexpEntry.key.id}"/>
        <h:commandLink value="#{cexpEntry.key.name} (#{cexpEntry.value})" action="#{search.doExperimentalFactorSearch}"/>
      </h:form>




      @Stateful
      @Name("search")
      @Conversational
      public class SearchAction implements Search, Serializable {
      ...
           @Begin(join = true)
           public String doExperimentalFactorSearch() {
                factorId = Long.parseLong(facesContext.getExternalContext().getRequestParameterMap().get("factorId").toString());
                experimentalFactorsSelected=em.createQuery(...).getResultList();
      
                isSimple = false;
                getResultCount();
                currentPage = 0;
                updateResults();
      
                return "searchResults";
           }
      ...
      }