Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 4 min read

Support

The Submit Element

One of the reasons that we have been careful to store all of our data in the model is that once this is done it makes it easy for a web client to simply serialize this model into XML and send it to a file, a web service, or possibly to a database.

This is all done by using a simple submit command. submit is really just a trigger with an attribute of submission that points to a submission element in the model. This is usually a button with the word "Submit" or "Save" on it that appears at the end of the form.

On many HTML forms you fill out the form and press a button at the bottom of the form called "Save" or "Submit". You pressed the button and hoped your data would get saved. This is the same concept. But in this case the submit command can be triggered in many ways other that just a button being pressed and there are explicit ways of getting feedback from the receiver that the submission process succeeded.

The submit event behaves exactly like a trigger but with one key exception, the xforms-submit event is also dispatched.

A model can have more than one submission identified by id

The first submission sends the data to the specified action, while the second one will expect to get a return xml to update the current document/instance.
The third one will save the file locally to the given location /tmp/final.xml

Screen Image

The interface is very simple. It is just a simple "Save" button created by a trigger called submit.

Sample Program

xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">

XForms Submit Example

xmlns="">

One
Two
Three

id="save" method="put" action="myData.xml" ref="/MyData"/>

submission="save">
Save

xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/20021/XMLSchema-instance">

Submission with get and put

id="data_instance" src="data.xml" xmlns="">
id="read-from-file" method="get" action="data.xml" replace="instance"
instance="data-instance">
id="save-to-file" method="put" action="data.xml" replace="instance"
instance="data_instance">

Demonstration of using XForms to get and put data to local file using the submission
element.

ref="Element1">
Element1:

/>
ref="Element2">
Element2:

/>
ref="Element3">
Element3:
/>

submission="read-from-file">
Reload

submission="save-to-file">
Save

Analysis

The save button is really just a trigger with the name of "submit" and an attribute called submission.

submission="save">

The attribute submission="save" points to the ID of the submission element inside the model.

id="save" method="put" action="myData.xml" ref="/MyData"/>

Note that because we used a "relative file name" (relative to the directory that the form was in) it will save the data in the same directory location that the form was located.

Discussion

You can also use absolute path names but you must be careful about how you describe a letter drive since there are no standards for this.

The following format worked for a Microsoft Windows system using the FireFox browser:

Web Server Configuration

Note: This section was written by a person that does not know much about web server administration. Read at your own risk and make sure a security professional reviews any changes to your public web servers.

Most of the examples in this tutorial are about learning XForms, not web server administration. That being said there are a few things we thought might be useful.

By default web servers are usually not configured to write files to your web server. Especially by un-authorized users. If this were the case hackers might use your web server to store their adult content.

To get XForms to save instance using "put", you should only allow writing to authorized users. To do this you will need to be able to administer your web server correctly.

Apache 2.2 Intranet Configuration with DAV

If you have a computer that is only accessible by internal users (usually called an Intranet) you can access, you can add the following to your Apache configuration file (usually called httpd.config and located in /usr/local/etc or similar location):

First, the following modules may have to be loaded:

mod_dav, mod_dav_fs, mod_dav_svn, mod_authz_svn.

This can be done by adding the following lines to your httpd.conf file:

LoadModule dav_module libexec/apache22/mod_dav.so
LoadModule dav_fs_module libexec/apache22/mod_dav_fs.so

DAV on
AllowOverride None
Order allow,deny
Allow from all

By turning on DAV you will enable all of the WebDAV operations including "PUT".

IIS Configuration

To be done...

References

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
action=" method="post" id="submit" includenamespaceprefixes=""/> action=" method="post" includenamespaceprefixes="#default"/> ## Sample Form xmlns=" xmlns:ev=" xmlns:xsd=" xmlns:xf=" xmlns:task=" task:dummy="dummy"> Test of XForms Submission Namespace Inclusion type="text/css"> @namespace xf url(" b
CC BY-SA 4.0
xmlns=" xmlns:ev=" xmlns:xhtml=" xmlns:xs=" xmlns:fr=" xmlns:xxforms=" xmlns:xf=" Save Test xmlns="" id="save-data"> form-id="unit-tests-save-test"> Dan McCreary xmlns="" id="save-results"> No Save Results Yet id="save-submission" ref="instance('save-data')" method="post" resource=" replace="instanc
CC BY-SA 4.0
Add the following instance to your model: xmlns="" id="log"> log initialized Whenever you want to see an event, just add an action that appends an event to the end of the log: ev:event="xforms-deselect"> nodeset="instance('log')/event" at="last()" position="after" /> ref="instance('log')/event[last(
CC BY-SA 4.0
First you need to give the control you want to receive the first keystroke event an **id** attribute. For example: id="first-field"> Search The next step is to use the **xforms-ready** event to set the focus to this field using the **setfocus** element. These initial actions are usually placed at th
CC BY-SA 4.0
id="tab-bar"> appearance="minimal"> Tab One case="case-1" ev:event="DOMActivate" /> appearance="minimal"> Tab Two case="case-2" ev:event="DOMActivate" /> appearance="minimal"> Tab Three case="case-3" ev:event="DOMActivate" /> id="case-1"> ev:event="xforms-select"> nodeset="instance('log')/event" at=
CC BY-SA 4.0
Here is the code for the action itself: ev:event="xforms-delete" ev:observer="people" if="not(person)"> origin="instance('person-template')" context="."/> This says to watch the **people** instance and if there is not a person in the people instance then insert one using the person-template instance