11 Replies Latest reply on Dec 10, 2007 1:11 PM by Manfred Maelzer

    setValueOnDOM - Nullpointer exception (on valid clientid)

    Manfred Maelzer Newbie

      Hi,

      I tried to submit a value for an input component. The first time it worked. Later on in process (second viewid with input field) this failed.

      The clientId exists (_idJsp28:runningHoursId) ... not only found by my code but also avaiable in client.getClientIds.allClientIds .


      java.lang.NullPointerException
       at org.jboss.jsfunit.facade.JSFClientSession.setValueOnDOM(JSFClientSession.java:230)
       at org.jboss.jsfunit.facade.JSFClientSession.setParameter(JSFClientSession.java:248)
       at de.docware.warranty.misc.oemfile.OEMClaimWorkflow.testJSFNavigation(OEMClaimWorkflow.java:121)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       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.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 javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.jsfunit.framework.JSFUnitFilter.doFilter(JSFUnitFilter.java:123)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
       at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
       at java.lang.Thread.run(Thread.java:534)
      


        • 1. Re: setValueOnDOM - Nullpointer exception (on valid clientid
          Manfred Maelzer Newbie

          Here is an excerpt of the HTML code of the specific page that fails with the client.setParameter command.

          <form id="_idJsp28" name="_idJsp28" method="post" action="/warranty/jsp/engine_warranty_enter_running_hours.jsf" enctype="application/x-www-form-urlencoded">
           <input type="hidden" name="dwSessionRequestTime" value="1196946982902" />
          
           <table><tbody><tr><td>Please Enter Details:</td></tr><tr><td><table><tbody><tr><td><label class="label" for="_idJsp28:_idJsp33">Date into service: </label></td><td>06-Nov-2007</td></tr><tr><td><label class="label" for="_idJsp28:_idJsp35">Running Hours: (*) </label></td><td><input id="_idJsp28:runningHoursId" name="_idJsp28:runningHoursId" type="text" value="" maxlength="6" class="inputField" /></td></tr>


          • 2. Re: setValueOnDOM - Nullpointer exception (on valid clientid
            Stan Silvert Master

            Hi,

            I haven't see that happen before. HttpUnit successfully set the value on the form, but it looks like this line of code in JSFClientSession returned null:

            Element element = DOMUtil.findElementWithID(clientID, this.updatedDOM);


            First, I would give my form an ID to make debugging a bit easier. So let's say we called it "form1".

            You can call this and verify that DOMUtil indeed returns null:

            Element element = DOMUtil.findElementWithID("form1:runningHoursId", client.getUpdatedDOM());
            System.out.println("element=" + element);


            If you have a something you can send me to reproduce the problem I'd appreciate it. Just create a new jira task at http://jira.jboss.com/jira/browse/JSFUNIT.

            Thanks,

            Stan

            • 3. Re: setValueOnDOM - Nullpointer exception (on valid clientid
              Manfred Maelzer Newbie

              I have written the DOM tree of the JSFUnit to the filesystem. The dom tree is still very old. It was from the very first page that i had to enter values for.

              After that it seems like the dom tree didnt get update.

              That's the process we do:
              /jsp/empty.jsp (action: select commandlink from toolbar)
              /jsp/start.jsp (action: select commandlink from main screen)
              /jsp/enter_page_1.jsp (action: enter value+ press continue)

              The viewId stays the same then (a "popup" layer is shown, which is then "clicked" away)

              /jsp/enter_page_2.jsp <<<<<< here there is still the old DOM Tree of enter_page_1.jsp (without popup)

              That is why there is a NULL Pointer exception. As I assume - due to the updated ViewID - that the new page would be loaded to enter the new value for.

              • 4. Re: setValueOnDOM - Nullpointer exception (on valid clientid
                Manfred Maelzer Newbie

                The only old value seems to be the DOM tree that is being held by the JSFClientSession. Having written the reponse stream to the console showed the correct html code for this.

                Maybe the client got confused with the "popup".

                The popup is a layer that is being rendered above the normal screen. It has outcomes just like the JSF pages too. Those outcomes may either just be "null" or calling a method for instance.

                The server session seems to be correct however.

                • 5. Re: setValueOnDOM - Nullpointer exception (on valid clientid
                  Stan Silvert Master

                  Can you tell me a little more about the popup? How is it created? What is the code you used to click it away?

                  If you used an HttpUnit WebRequest (such as PostMethodWebRequest or GetMethodWebRequest) then you need to call JSFClientSession.doWebRequst().

                  Stan

                  • 6. Re: setValueOnDOM - Nullpointer exception (on valid clientid
                    Manfred Maelzer Newbie

                    This is how the "popup" - if found - is handled.
                    The "popup" in this case is a managed bean. I read it, if it has the attribute "isVisible" set to true. If so - i call this method:

                    private boolean handlePopup(PopupBean popup, FacesContext context) throws IOException, SAXException {
                     AbstractProfile profile = (AbstractProfile)JSFUtils.getManagedBean("profile");
                     UIComponent popupContainer = JSFUtils.findComponentInRoot("popup");
                    // String displayedText = findDisplayedPopupText(popup);
                     List commandButtons = JSFUtils.findComponentsByRendererType(popupContainer, JSFConstants.JSF_RENDERER_COMMANDBUTTON, new ArrayList());
                     List allowedCommands = unitTransferBean.getAllowedPopupCommands(server.getCurrentViewID());
                     for (int i = 0; i < allowedCommands.size(); i++) {
                     String bundleKey = (String)allowedCommands.get(i);
                     String translation = profile.getTranslationMap().getProperty(bundleKey);
                     for (int j = 0; j < commandButtons.size(); j++) {
                     UICommand commandButton = (UICommand)commandButtons.get(j);
                     String commandButtonLabel = (String)commandButton.getValue();
                     if (translation.equals(commandButtonLabel)) {
                     client.submit(commandButton.getClientId(context));
                     return true;
                     }
                     }
                     }
                     return false;
                     }


                    There is different types of "popups". like a messagedialog - none of them does inherit popup but they set the "isVisible" to true and the "dialog_page" of popup managed bean to the page to be displayed if they are being shown.

                    This is how such a MesageDialog may be invoked in the application:
                    return MessageDialogBean.show(text, profile, "showEmpty");


                    On each page there is a jsp page included. In this JSP page the popup bean is examined. If isVisible==true the displayed page will be included (jsp aswell) - as a layer with high z-index.

                    Reading the serverside components list the popup related components too then (subviewid="popup"). So i read the commandbuttons from within the subview and press one that matches my allowed component labels.

                    Serverside this all works. The problem is that the client doesnt update itself

                    Do you require more information on how it works?

                    • 7. Re: setValueOnDOM - Nullpointer exception (on valid clientid
                      Manfred Maelzer Newbie

                      Ah - the .show method returns "null" of course. So the Message Dialog just invokes an additional layer on the old viewId page that was shown.

                      The dialog may have one or more command buttons actions. When clicked the "isVisible" is set to false again. So when "null" is the return value, the old page will be shown again without an additional layers ontop.

                      • 8. Re: setValueOnDOM - Nullpointer exception (on valid clientid
                        Stan Silvert Master

                        From your last comment, it sounds like you figured it out? Are you still having a problem?

                        Stan

                        • 9. Re: setValueOnDOM - Nullpointer exception (on valid clientid
                          Manfred Maelzer Newbie

                          No, sadly the problem still exists. The last post just was supposed to make the functionality a bit clearer to you...

                          • 10. Re: setValueOnDOM - Nullpointer exception (on valid clientid
                            Stan Silvert Master

                            http://jira.jboss.com/jira/browse/JSFUNIT-64

                            I think I fixed it now. I changed JSFClientSession. Can you try a new build from subversion? Note that the snapshot version has changed so the jar will have a different name.

                            I'm headed for Javapolis now, so I probably won't be able to get back to you for a day or two.

                            Stan