6 Replies Latest reply on Dec 6, 2010 9:57 AM by ole .

    a4j:actionparam never set on backbean with client.click

    Adrien Adrien Apprentice

      Hello,
      I don't know how, when i click on a panelbaritem, the actionparam is never set on the backbean, with manual test all works, but my jsfunit test is certainly bad, here the xhml and jsfunit code

      Here a part of my page

      <rich:panelBar id="mg" immediate="true" height="300">
      
       <rich:panelBarItem label="Code postal" id="pcp" >
       <a4j:support event="onenter" ajaxSingle="true" immediate="true" >
       <a4j:actionparam name="geotype" value="scp" assignTo="#{ctrlFullSearch.form.geoSearchType}"/>
       </a4j:support>
       </rich:panelBarItem>
      
      <rich:panelBarItem label="Departements" id="pdpt">
       <a4j:support event="onenter" ajaxSingle="true" immediate="true" >
       <a4j:actionparam name="geotype" value="sdpt" assignTo="#{ctrlFullSearch.form.geoSearchType}"/>
       </a4j:support>
      
       </rich:panelBarItem>
      </rich:panelBar >


      Here what i do in my test:

      client.click("subviewa:formtest:pdpt");
      client.click("subviewa:formtest:button");
      //I have set a big log in backbean and geoSearchType never appear
      


      Anybody has an idea?
      Thanks
      Adrien

        • 1. Re: a4j:actionparam never set on backbean with client.click
          Tim Evers Master

          Are you sure that the click is actually occuring, and are you clicking on the correct thing?

          Many components render multiple html elements and you need to be clicking on the correct html element.

          • 2. Re: a4j:actionparam never set on backbean with client.click
            Stan Silvert Master

            Your event for a4j:support is "onenter". The JSFUnit click will only trigger events associated with a mouse click. So I don't think your "onenter" will be triggered. Frankly, I don't know exactly how RichFaces renders the HTML in that case.

            Like Kragoth said, you will need to see how the HTML is actually rendered. I've found that the FireFox Firebug plugin is very helpful for situations like this.

            Stan

            • 3. Re: a4j:actionparam never set on backbean with client.click
              Adrien Adrien Apprentice

              Hi
              fire bug is magic ;-)
              This is that on enter isn't triggered.
              Thanks

              • 4. Re: a4j:actionparam never set on backbean with client.click
                Stan Silvert Master

                Yeah, I don't think I could have delivered JSFUnit without FireBug. It saves me hours of debugging.

                So I take it that your problem is now solved? Can you post the solution? I don't think I have any unit tests that use "onenter".

                Thanks,

                Stan

                • 5. Re: a4j:actionparam never set on backbean with client.click
                  Adrien Adrien Apprentice

                  Actually i ve not found good solution.
                  I've trying with htmlunit :


                  HtmlPage htmlPage = (HtmlPage)client.getContentPage();
                   ClickableElement clickable = (ClickableElement)htmlPage.getElementById(getPanelID(p));
                   try {
                   clickable.click();


                  but an exception occurs :


                  TypeError: Cannot read property "action" from null (http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf#187)

                  ======= EXCEPTION START ========
                  EcmaError: lineNumber=[187] column=[0] lineSource=[null] name=[TypeError] sourceName=[http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf] message=[TypeError: Cannot read property "action" from null (http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf#187)]
                  com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "action" from null (http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf#187)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:513)
                  at org.mozilla.javascript.Context.call(Context.java:515)
                  at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:444)
                  at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:961)
                  at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:152)
                  at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:165)
                  at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:576)
                  at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:916)
                  at org.mozilla.javascript.Context.call(Context.java:515)
                  at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
                  at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:921)
                  at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:136)
                  at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:107)
                  at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:76)
                  at org.jboss.jsfunit.jsfsession.JSFClientSession.click(JSFClientSession.java:226)
                  at com.horizon.web.jsf.searches.CommonsTestsSearches.search(CommonsTestsSearches.java:197)
                  at com.horizon.web.jsf.searches.CommonsTestsSearches.searchAndCheckUserPresent(CommonsTestsSearches.java:181)
                  at com.horizon.web.jsf.searches.CtrlFullSearchesTest.testGeo_CP_Dpts_2dpt(CtrlFullSearchesTest.java:412)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
                  at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
                  at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
                  at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
                  at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
                  at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
                  at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
                  at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
                  at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:46)
                  at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
                  at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
                  at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
                  at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:52)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:116)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
                  at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
                  at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
                  at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                  at java.lang.Thread.run(Thread.java:619)
                  Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "action" from null (http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf#187)
                  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
                  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
                  at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)
                  at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)
                  at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3692)
                  at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1421)
                  at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3027)
                  at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
                  at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
                  at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
                  at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:192)
                  at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
                  at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
                  at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:82)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:472)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:437)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:507)
                  ... 67 more
                  Enclosed exception:
                  org.mozilla.javascript.EcmaError: TypeError: Cannot read property "action" from null (http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf#187)
                  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
                  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
                  at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)
                  at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)
                  at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3692)
                  at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1421)
                  at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3027)
                  at script(http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf:187)
                  at script(http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf:154)
                  at script(http://localhost:8080/a4j/g/3_3_0.GAorg.ajax4jsf.javascript.AjaxScript.jsf:156)
                  at script(onclick event for HtmlButtonInput[<input id="svfs:fsf:search" name="svfs:fsf:search" onclick="A4J.AJAX.Submit('_viewRoot','svfs:fsf',event,{'similarityGroupingId':'svfs:fsf:search','parameters':{'svfs:fsf:search':'svfs:fsf:search'} ,'actionUrl':'/pages/m/searchfull.jsf'} );return false;" value="chercher" type="button">] in http://localhost:8080/pages/m/searchfull.jsf)
                  at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
                  at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
                  at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
                  at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:192)
                  at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
                  at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
                  at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:82)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:472)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:437)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:507)
                  at org.mozilla.javascript.Context.call(Context.java:515)
                  at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
                  at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:444)
                  at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:961)
                  at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:152)
                  at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:165)
                  at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:576)
                  at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:916)
                  at org.mozilla.javascript.Context.call(Context.java:515)
                  at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
                  at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:921)
                  at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:136)
                  at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:107)
                  at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:76)
                  at org.jboss.jsfunit.jsfsession.JSFClientSession.click(JSFClientSession.java:226)
                  at com.horizon.web.jsf.searches.CommonsTestsSearches.search(CommonsTestsSearches.java:197)
                  at com.horizon.web.jsf.searches.CommonsTestsSearches.searchAndCheckUserPresent(CommonsTestsSearches.java:181)
                  at com.horizon.web.jsf.searches.CtrlFullSearchesTest.testGeo_CP_Dpts_2dpt(CtrlFullSearchesTest.java:412)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
                  at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
                  at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
                  at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
                  at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
                  at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
                  at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
                  at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
                  at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doPost(JSFUnitServletRedirector.java:46)
                  at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
                  at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
                  at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
                  at org.jboss.jsfunit.framework.JSFUnitServletRedirector.doGet(JSFUnitServletRedirector.java:52)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:116)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
                  at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
                  at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
                  at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                  at java.lang.Thread.run(Thread.java:619)
                  == CALLING JAVASCRIPT ==
                  function () {
                  [native code, arity=0]
                  }

                  ======= EXCEPTION END ========



                  And to change manually my bakcbean :

                  FacesContext facesContext = FacesContext.getCurrentInstance();
                   return facesContext.getApplication().getVariableResolver().resolveVariable(facesContext, backBeanId);

                  In this case the backbean is updated.
                  But an exception occurs because my panel is not opened.

                  I continue to search
                  Adrien



                  • 6. Re: a4j:actionparam never set on backbean with client.click
                    ole . Newbie

                    I know the thread is >1year old. Did you find any solution? I have the same problem now.