2 Replies Latest reply on Mar 24, 2010 4:31 PM by Michael Wohlfart

    Postback detection in integration tests problem for JSF 1.2

    Michal Orman Newbie


      I've noticed following problem during creating integration tests. I want to invoke action but not on postback, so I add following declaration in pages.xml file:

      <action execure="#{bean.action}" on-postback="false" />

      Everything works well if I deploy on server and test action (action is called once, and not on postback), but when I wrote integration test for this the action isn't called at all.

      During investigation I found out that responsible for determination of postback is MockResponseStateManager class. The problem is that it uses default implementation of isPostback method, which looks as follows:

      public boolean isPostback(FacesContext context) {
          return (!context.getExternalContext().getRequestParameterMap().isEmpty());

      And here is a problem. This method returns true if context contains (URL) parameters, and my pages.xml defines URL parameters for this view. So it seams that each time page defines URL parameters it is evaluated as postback (even if only 1st and 6th JSF phase was called).

      I was wondering why then it works on server. It works because ResponseStateManagerImpl from jsf-impl which is used on server overrides isPostback method in following way:

      public boolean isPostback(FacesContext context) {
          return context.getExternalContext().getRequestParameterMap().

      And this method correctly (in my case) determines postback (even if request has parameters).

      Does anybody noticed similar problem? Is this a bug or feature? Does anybody known any workaround for this problem?