3 Replies Latest reply on Jun 13, 2008 8:35 AM by ssilvert

    JSFClientSession.submit not working with h:commandButton

      I'm using JSFUnit Beta 2 and am having problems getting JSFClientSession.submit to work properly with h:commandButton. I should note that we're also using RichFaces 3.2.X and Facelets. I have a simple test that clicks a button in the footer of a rich:dataTable (not sure if that part matters) like so:

      <h:commandButton id="myButton"
       onclick="if (!confirm('Are you sure?')) return false;"
       value="Submit"
       action="#{bean.action}"/>
      

      The action performs some logic and returns the navigation case for the next page. If I use JSFClientSession.submit("myButton") in the test code, the button is pressed but the action code is never executed. The strange part is that it appears the page navigated correctly via JSFServerSession.getCurrentViewId(). (must be just luck)

      However, it all works correctly if I use RichFacesClient.ajaxSubmit("myButton"). I don't understand why. Does the javascript have anything to do with it? The only other thing I can think of is that the test performs other ajaxSubmits before clicking myButton that might interfere?

      Justin

        • 1. Re: JSFClientSession.submit not working with h:commandButton
          ssilvert

          I don't think its luck! :-)

          If JSF navigated correctly to a new page then surely it performed #{bean.action} and returned the proper String. How do you know that the action was not performed?

          Stan

          • 2. Re: JSFClientSession.submit not working with h:commandButton

            Well I know it's not really luck, but it is bizarre. I have no idea where it is getting the navigation rule. When I use RichFacesClient.ajaxSubmit("myButton"), all goes well and I see all my debug in the action routine. When I change just that one line to JSFClientSession.submit("myButton"), I no longer see my action() debug but JSFServerSession.getCurrentViewID() tells me I've navigated to the correct page. I even commented out the entire action() logic and returned null with the same result.

            • 3. Re: JSFClientSession.submit not working with h:commandButton
              ssilvert

              It could be that RichFaces is doing something weird. Note that we will soon be switching to HtmlUnit for handling this and it works in a different way. You can read about that in the first post of this forum.

              Stan