Created
July 5, 2011 01:47
-
-
Save terrancesnyder/1064145 to your computer and use it in GitHub Desktop.
Load initial form data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" | |
xmlns:xforms="http://www.w3.org/2002/xforms" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:ev="http://www.w3.org/2001/xml-events" | |
xmlns:xi="http://www.w3.org/2001/XInclude" | |
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" | |
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" | |
xmlns:exforms="http://www.exforms.org/exf/1-0" | |
xmlns:fr="http://orbeon.org/oxf/xml/form-runner" | |
xmlns:saxon="http://saxon.sf.net/" | |
xmlns:sql="http://orbeon.org/oxf/xml/sql" | |
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | |
<xhtml:head> | |
<xhtml:title>Untitled Form</xhtml:title> | |
<xforms:model id="fr-form-model"> | |
<!-- Main instance --> | |
<xforms:instance id="fr-form-instance"> | |
<form> | |
<mySection> | |
<firstName/> | |
</mySection> | |
</form> | |
</xforms:instance> | |
<!-- User in which user data is collected --> | |
<xforms:instance id="user-data"> | |
<registration> | |
<first-name>?</first-name> | |
<last-name/> | |
</registration> | |
</xforms:instance> | |
<!-- Load initial data from a service --> | |
<xforms:send ev:event="xforms-model-construct-done" submission="load-data-submission"/> | |
<xforms:submission id="load-data-submission" method="get" serialization="none" | |
resource="http://localhost:7001/load-initial-form-data-pull-instance.xml" | |
replace="instance" | |
instance="user-data"/> | |
<!-- force reloading of default values on ready --> | |
<xforms:action ev:event="xforms-ready"> | |
<xforms:recalculate xxforms:defaults="true"/> | |
</xforms:action> | |
<!-- Bindings --> | |
<xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')"> | |
<xforms:bind id="mySection-bind" nodeset="mySection" name="mySection"> | |
<xforms:bind id="firstName-bind" nodeset="firstName" name="firstName" type="xforms:string" | |
xxforms:default="instance('user-data')/first-name"/> | |
</xforms:bind> | |
</xforms:bind> | |
<!-- Metadata --> | |
<xforms:instance id="fr-form-metadata" xxforms:readonly="true"> | |
<metadata> | |
<application-name>helloworld</application-name> | |
<form-name>form</form-name> | |
<title xml:lang="en">Untitled Form</title> | |
<description xml:lang="en"/> | |
<author/> | |
<logo mediatype="" filename="" size=""/> | |
</metadata> | |
</xforms:instance> | |
<!-- Attachments --> | |
<xforms:instance id="fr-form-attachments"> | |
<attachments> | |
<css mediatype="text/css" filename="" size=""/> | |
<pdf mediatype="application/pdf" filename="" size=""/> | |
</attachments> | |
</xforms:instance> | |
<!-- All form resources --> | |
<!-- Don't make readonly by default in case a service modifies the resources --> | |
<xforms:instance id="fr-form-resources" xxforms:readonly="false"> | |
<resources> | |
<resource xml:lang="en"> | |
<mySection> | |
<label>Untitled Section</label> | |
<help/> | |
</mySection> | |
<firstName> | |
<label>First name</label> | |
<hint/> | |
<help/> | |
<alert/> | |
</firstName> | |
</resource> | |
</resources> | |
</xforms:instance> | |
<!-- Utility instances for services --> | |
<xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all"> | |
<request/> | |
</xforms:instance> | |
<xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all"> | |
<response/> | |
</xforms:instance> | |
</xforms:model> | |
</xhtml:head> | |
<xhtml:body> | |
<fr:view> | |
<xforms:label ref="instance('fr-form-metadata')/title"/> | |
<fr:body> | |
<fr:section id="mySection-section" bind="mySection-bind"> | |
<xforms:label ref="$form-resources/mySection/label"/> | |
<xforms:help ref="$form-resources/mySection/help"/> | |
<fr:grid columns="2"> | |
<xhtml:tr> | |
<xhtml:td> | |
<xforms:input id="firstName-control" bind="firstName-bind"> | |
<xforms:label ref="$form-resources/firstName/label"/> | |
<xforms:hint ref="$form-resources/firstName/hint"/> | |
<xforms:help ref="$form-resources/firstName/help"/> | |
<xforms:alert ref="$fr-resources/detail/labels/alert"/> | |
</xforms:input> | |
</xhtml:td> | |
<xhtml:td> | |
</xhtml:td> | |
</xhtml:tr> | |
</fr:grid> | |
</fr:section> | |
</fr:body> | |
</fr:view> | |
</xhtml:body> | |
</xhtml:html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simpler example showing the use of <xforms:recalculate xxforms:defaults="true"/> to recalculate default values so that our submission data can be used as defaults.