XForms/Insert with Origin

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Motivation[edit | edit source]

You want to insert new values into an instance of the model and specify where to find the initial values of the insert.

Method[edit | edit source]

You can add an origin attribute to the insert statement to tell XForms where to get the initial data for the insert. This is the preferred method over doing many setvalues. The syntax of the insert is the following:

<xf:insert ev:event="DOMActivate" 
   at="last()" position="after"

Screen Image[edit | edit source]

A sample screen image. Many people do not have the ability to run the examples so this is critical.

Use this format:

This is my caption

Make SURE you label all images with a license. Please use creative commons "share alike 3.0 with attribution" if you can.

XForms Application[edit | edit source]

Load XForms Application

Make sure that the mime-type is set in the svn system to be text/xml.

Sample XForms Template[edit | edit source]

       <title>Insert with Origin</title>
       <style type="text/css">
          @namespace xf url("http://www.w3.org/2002/xforms");
          body {font-family:Helvetica, sans-serif}
          <xf:instance xmlns="" id="persons">
		 <xf:bind nodeset="XFormsAwareIndicator" type="xs:boolean"/>
		 <!-- initial values for new Person records -->
		 <xf:instance xmlns="" id="init">
       <h3>Insert with Origin</h3>
		<xf:repeat nodeset="Person" id="person-repeat">
         <xf:input ref="PersonGivenName">
            <xf:label>First Name: </xf:label>
	 <xf:input ref="PersonFamilyName">
            <xf:label>Family Name: </xf:label>
		 <xf:select1 ref="PersonGenderCode">
            <xf:label>Gender: </xf:label>
		 <xf:input ref="XFormsAwareIndicator">
            <xf:label>Indicator: </xf:label>
			 <xf:insert ev:event="DOMActivate" nodeset="instance('persons')/Person" at="last()" position="after"

Discussion[edit | edit source]

Next Page: Delete | Previous Page: Insert
Home: XForms