1 Reply Latest reply on Feb 29, 2008 8:21 AM by Steffen Grimm

    problem: getting FacesContext object is not singeton after a

    Chunlei Li Newbie

      I'm having a problem getting FacesContext object after add richfaces jars in classpath:

      richfaces-ui-3.1.4.GA.jar

      richfaces-impl-3.1.4.GA.jar

      richfaces-api-3.1.4.GA.jar

      code:

      FacesContext context = FacesContext.getCurrentInstance();




      I get different "context" object every time after run above code.

      But in a application, FacesContext.getCurrentInstance() should be singleton usually.



      Below is my code:



      jsp:



      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      
      <HTML>
      
      <HEAD>
      
      
      
      <TITLE>test2.jsp</TITLE>
      
      
      
      </HEAD>
      
      <BODY>
      
      <f:view>
      
      
      
       <a4j:form>
      
       <a4j:commandButton actionListener="#{testBean.testAction2}" value="testeeeee" ajaxSingle="true"></a4j:commandButton>
      
       </a4j:form>
      
      </f:view>
      
      </BODY>
      
      </HTML>
      



      java code:

      public void testAction2(ActionEvent event)
      
      {
      
       FacesContext context = FacesContext.getCurrentInstance();
      
       System.out.println(context);
      
      }