udar_molota
udar_molota

Reputation: 273

jsf 2.0 working with javascript prevents ajax call

I'm working on a JSF 2 project. Got some javascript/jQuery functions on client side, after calling for all these functions <a4j:commandButton> is not working. I get

Servlet.service() for servlet Faces Servlet threw exception: java.lang.NullPointerException 
    at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:441)

If I change <a4j:commandButton> to <h:commandButton>, then everything works fine, but I need the a4j because of oncomplete attribute.

How can I debug this issue? It looks like problem with javascript event, that prevents ajax call.

Upvotes: 3

Views: 338

Answers (1)

JustinKSU
JustinKSU

Reputation: 4989

I have tracked down this problem to determine it is due to a <button> tag being in the html.

For example:

<!DOCTYPE html>
<html lang="en" 
xmlns="http://www.w3.org/1999/xhtml" 
xmlns:h="http://java.sun.com/jsf/html" 
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
</h:head>
<h:body>
    <h:form id="example">
        <a4j:commandButton type="submit" value="Submit" />
        <button>button</button>
    </h:form>
</h:body>
</html>

My theory is the JavaScript that is submitting the AJAX is somehow confused by the <button> tag in IE7 causing an invalid post to the server.

Without seeing your HTML, I can't be certain this is your issue.

Check the following JIRA posts for more information.

http://java.net/jira/browse/JAVASERVERFACES-2666

https://issues.jboss.org/browse/RF-12693

Pavol Pitonak over at RichFaces discovered that if you add a name attribute to the <button> then the error will go away.

Upvotes: 1

Related Questions