Search code examples
javatomcatservletsorbeonxforms

Submit (post) form to Java Servlet using Orbeon XForms


I am trying to execute the simplest of tasks and that is to submit a form to a Java Servlet using XForms (orbeon).

<xforms:submission id="login-submit" ref="instance('login-instance')" resource="/Login/login.do" method="urlencoded-post" mediatype="application/xml" replace="all">

When I click the Submit button I get :

Type    class java.lang.NullPointerException
Message null
Location    oxf:/ops/xforms/xforms-server-submit.xpl
Line    73
Column  51
Stack Trace 

java.lang.NullPointerException
..

Along with large stacktrace. I know the servlet works as using a standard HTML form logs me in to the site. I've spent a long time on this trying to get it to work and at a loss. I'm using Orbeon v3.9.1 PE and an evaluation license, Tomcat 7.0.32, and v1.7.0_07 of the JRE.


Solution

  • I see some parameters are missing. See the below example which you can understand and accordingly use your parameter values.

    <xforms:submission id="submission-id" ref="instance('form-instance')"
            action="http://localhost:8080/mywebapp/servlets/servlet/TestServlet" 
            method="post" replace="none"
            validate="false">
        <xforms:message ev:event="xforms-submit-done" level="modal" value="'Submission Successful'"/>
        <xforms:message ev:event="xforms-submit-error" level="modal" value="'Submission failed'"/>
    </xforms:submission>
    

    Test the url given in action first to see whether the servlet is configured correctly or not.

    You can test your submission functionality and it is given here. You can add the xforms-submit-done and xforms-submit-error events to check which event is getting thrown.