Debugging XForms at runtime has not been easy. It seems difficult to get simple and convenient access to the XForms instance data while the user is interacting with the form. I find that I want to test an XPath expression or XForms action (e.g. setvalue).
My development environment is Eclipse, with embedded Tomcat as the server. Testing the interface is through FireFox, and I have Firebug installed to monitor web server calls. Firebug does provide access to the DOM, and I guess this should mean I can look into the instance nodes. However this is less than straightforward.
In the end I realised that I could create a simple debug tool to inspect the instance data. By adding a "Debug" button to the form, I can submit an instance data back to the server. I created a simple DebugXFormsSubmission JSP. The JSP does nothing more than output the submitted data to the server's stdout. Which Eclipse captures nicely from the embedded server and displays in the Console view.
The text of the JSP is:
<%@ page language="java" contentType="text/xml; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.io.BufferedReader" %>
<%
String xml = new String("");
String thisLine;
BufferedReader br = request.getReader();
while ((thisLine = br.readLine()) != null) {
xml = xml.concat(thisLine);
}
System.out.println("Received xml: ");
System.out.println(xml);
System.out.println("Done");
%>
The Debug submission in the form is:
<xf:submission id="submitDebug"
method="post"
replace="none"
ref="instance('data')"
action="/Leads/DebugXFormsSubmission.jsp"
omit-xml-declaration="true">
</xf:submission>
The Debug button is:
<xf:submit submission="submitDebug">
<xf:label>Debug</xf:label>
</xf:submit>
This has become a simple but invaluable means of getting quick access to the instance data. And it has no impact on the actual instance itself.
Tuesday, July 1, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment