NPE in htmlunit when testing ajax rendering
-------------------------------------------

                 Key: MYFACES-2748
                 URL: https://issues.apache.org/jira/browse/MYFACES-2748
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-314
    Affects Versions: 2.0.1-SNAPSHOT
            Reporter: Michael Concini


When attempting to run some simple ajax  tests using htmlunit, we're seeing 
some NPEs when running in the default (IE) client mode.  As before with 
MYFACES-2745 this looks like its a bug in htmlunit, however these test cases 
had been passing on the MyFaces 2.0.0 release so something that is going on 
with the new javascript must be triggering the bug.  I've validated in IE8, 
Firefox 3.6 and Chrome that this is being rendered properly in a live browser 
session as well as that it works if you initialize the htmlunit with new 
WebClient(BrowserVersion.FIREFOX_3).

Here's a simple example of a failing case.  Its just executes an increment 
action on a counter var and uses f:ajax to re-render an outputText field. 
    <h:form id="form1" prependId="false">
        <h:outputText id="out1" value="#{incrementdecrement.value}"/>
        <br/>
        <h:commandButton id="button1" value="Count" 
action="#{incrementdecrement.increment}" >
            <f:ajax render="out1" disabled="false"  />
        </h:commandButton>
        <br/>
    </h:form>

After doing some debugging, htmlunit doesn't seem to be handling the partial 
page update.  Instead of updating the span value for "out1", it is actually 
removing it from the idMap for the page.  So if you try to validate the value 
of "out1" has been incremented, you'll get an NPE since the element is no 
longer on the idMap.

        WebClient webClient = new WebClient();       
        HtmlPage page = (HtmlPage) webClient.getPage 
("http://localhost:8080/JSF20AJAXTag/DisabledFalse.jsf";);
        String buttonId = "button1";
        doClick(page,buttonId);
       
        Assert.assertEquals( "1", page.getElementById 
("out1").getTextContent());

The NPE is coming from trying to execute getTextContent() when 
page.getElementById("out1") is returning null.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to