<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stefan Cameron on Forms &#187; Tutorials</title>
	<atom:link href="http://forms.stefcameron.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://forms.stefcameron.com</link>
	<description>Building intelligent forms using Adobe LiveCycle Designer</description>
	<lastBuildDate>Fri, 10 Sep 2010 11:20:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>New Web Service Sample Form Posted</title>
		<link>http://forms.stefcameron.com/2010/09/02/new-web-service-sample-form-posted/</link>
		<comments>http://forms.stefcameron.com/2010/09/02/new-web-service-sample-form-posted/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 16:44:28 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=564</guid>
		<description><![CDATA[It was recently brought to my attention that the web service used by my sample form for my tutorial on connecting a form to a web service is no longer operational. Obviously, that makes the sample form much less useful so I have posted a second sample form that uses a different web service. If [...]]]></description>
			<content:encoded><![CDATA[<p>It was recently brought to my attention that the web service used by my sample form for my tutorial on <a href="http://forms.stefcameron.com/2007/05/21/connecting-to-a-web-service/">connecting a form to a web service</a> is no longer operational. Obviously, that makes the sample form much less useful so I have posted a second sample form that uses a different web service. If you have been struggling with the original sample, please have a look at the new one I posted in an <a href="http://forms.stefcameron.com/2007/05/21/connecting-to-a-web-service/">update</a> to the original post.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2010/09/02/new-web-service-sample-form-posted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show the List of a Drop Down List</title>
		<link>http://forms.stefcameron.com/2010/05/31/show-the-list-of-a-drop-down-list/</link>
		<comments>http://forms.stefcameron.com/2010/05/31/show-the-list-of-a-drop-down-list/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 03:06:12 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=548</guid>
		<description><![CDATA[Did you know that the list portion of a drop down list field can be displayed programmatically? You can set focus to the field and force its drop list to be displayed all in a single API call: xfa.host.openList(@object) xfa.host.openList(@string) -- deprecated since XFA 2.6 where @object is a reference to the drop down list [...]]]></description>
			<content:encoded><![CDATA[<p>Did you know that the list portion of a drop down list field can be displayed programmatically? You can set focus to the field and force its drop list to be displayed all in a single API call:</p>
<pre><code>xfa.host.openList(@object)
xfa.host.openList(@string) -- deprecated since XFA 2.6</code></pre>
<p>where @object is a reference to the drop down list field and @string is the SOM expression of the drop down list field.</p>
<pre><code>xfa.host.openList(myDropDownList); // set focus/show the drop list</code></pre>
<p>The second form of the API has been deprecated since XFA 2.6 which means that since Designer 8.1, it is preferred to use the first form which takes a reference to the field rather than its SOM expression.</p>
<p>If you&#8217;re using Designer 8.0 or earlier, you can get the SOM expression of any field by using its <em>somExpression</em> property:</p>
<pre><code>xfa.host.openList(ddlInDesigner71.somExpression)</code></pre>
<p>This works in both JavaScript and FormCalc with the same syntax.</p>
<p>Now if only there was a way to programmatically show the drop calendar of a date/time field&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2010/05/31/show-the-list-of-a-drop-down-list/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Border and Margins in Flowed Layouts</title>
		<link>http://forms.stefcameron.com/2010/04/21/border-and-margins-in-flowed-layouts/</link>
		<comments>http://forms.stefcameron.com/2010/04/21/border-and-margins-in-flowed-layouts/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 11:31:48 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=546</guid>
		<description><![CDATA[My friends at Avoka have posted a very useful tutorial on the unexpected behavior of borders in flowed layouts and how to use margins to fix it. Check it out!]]></description>
			<content:encoded><![CDATA[<p>My friends at <a href="http://www.avoka.com/">Avoka</a> have posted a very useful tutorial on the unexpected behavior of borders in flowed layouts and how to use margins to fix it. <a href="http://www.avoka.com/blog/?p=756">Check it out!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2010/04/21/border-and-margins-in-flowed-layouts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Acrobat JavaScript Debugger on XFA Forms</title>
		<link>http://forms.stefcameron.com/2010/03/12/acrobat-javascript-debugger-on-xfa-forms/</link>
		<comments>http://forms.stefcameron.com/2010/03/12/acrobat-javascript-debugger-on-xfa-forms/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 17:14:30 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=526</guid>
		<description><![CDATA[Many of you have been requesting some debugging features for XFA Forms (and I&#8217;m sure many more of you just haven&#8217;t voted for it yet). It so happens that Acrobat Pro has a JavaScript Debugger which can be used &#8212; to a limited extent &#8212; with XFA Forms. See John Brinkman&#8217;s post to learn more [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://forms.stefcameron.com/featur-o-meter/">Many of you</a> have been requesting some debugging features for XFA Forms (and I&#8217;m sure many more of you just haven&#8217;t voted for it yet). It so happens that Acrobat Pro has a <strong>JavaScript Debugger</strong> which can be used &#8212; to a <strong>limited</strong> extent &#8212; with XFA Forms. See <a href="http://blogs.adobe.com/formfeed/2010/03/using_the_acrobat_javascript_d.html">John Brinkman&#8217;s post</a> to learn more about it &#8212; thanks John!</p>
<p>As he puts it, <strong>there are limitations</strong>, the biggest ones of them being, in my opinion, the inability to debug script objects and the inability to retain breakpoints between debugging sessions. Nonetheless, this tool can give you way more insight than the good old &#8220;<a href="http://forms.stefcameron.com/2006/05/05/debugging-scripts/">JavaScript Console</a> + <a href="http://forms.stefcameron.com/2009/08/19/tip-pretty-xml-strings/">saveXML(&#8216;pretty&#8217;)</a>&#8221; combination can in certain cases, and it does it in a nice tree to boot!</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2010/03/12/acrobat-javascript-debugger-on-xfa-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tech Talk on Database Connected Forms</title>
		<link>http://forms.stefcameron.com/2010/03/10/tech-talk-on-database-connected-forms/</link>
		<comments>http://forms.stefcameron.com/2010/03/10/tech-talk-on-database-connected-forms/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 09:46:15 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=522</guid>
		<description><![CDATA[Paul Guerette, a colleague of mine at Adobe, will be giving a &#8220;tech talk&#8221; eSeminar on connecting forms to databases over at AcrobatUsers.com on Tuesday, March 23, 2010, at 10am PST (1pm EST). If you have been struggling with connecting a form to a database, are wanting to know what the best practices and/or security [...]]]></description>
			<content:encoded><![CDATA[<p>Paul Guerette, a colleague of mine at <a href="http://adobe.com/">Adobe</a>, will be giving a &#8220;tech talk&#8221; eSeminar on <a href="http://www.acrobatusers.com/events/2220/tech-talk-database-connected-forms">connecting forms to databases</a> over at <a href="http://acrobatusers.com/">AcrobatUsers.com</a> on Tuesday, March 23, 2010, at 10am PST (1pm EST).</p>
<p>If you have been struggling with connecting a form to a database, are wanting to know what the best practices and/or security concerns are, or have some specific questions you would like to ask, I highly recommend you attend the session. It&#8217;s <strong>free</strong> to attend (and free to become a member in order to attend)!</p>
<p>I&#8217;ll be answering chat questions &#8220;live&#8221; as the session unfolds. I hope you can join us!</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2010/03/10/tech-talk-on-database-connected-forms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Disabling All Fields Within a Subform</title>
		<link>http://forms.stefcameron.com/2010/03/08/disabling-all-fields-within-subform/</link>
		<comments>http://forms.stefcameron.com/2010/03/08/disabling-all-fields-within-subform/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 02:27:29 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=513</guid>
		<description><![CDATA[I thought I would point-out a nice improvement that was made to XFA &#60;subform&#62; elements back in XFA 2.8: The addition of the access property. In days of yore, if you wanted to disable all fields and exclusion groups (for the sake of brevity, I&#8217;ll refer to these collectively as &#8220;fields&#8221; in this article) in [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would point-out a nice improvement that was made to XFA &lt;subform&gt; elements back in <a href="http://partners.adobe.com/public/developer/xml/index_arch.html#xfa_28">XFA 2.8</a>: The addition of the <em>access</em> property.</p>
<p>In days of yore, if you wanted to disable all fields and exclusion groups (for the sake of brevity, I&#8217;ll refer to these collectively as &#8220;<em>fields</em>&#8221; in this article) in a particular section of your form, you would&#8217;ve had to write a script that recursively drilled down into all children of that section looking for <em>fields</em> to disable. This is because the access attribute only applied to <em>fields</em>.</p>
<p>With this change, assuming the section in question is contained within a subform, you can now easily disable all <em>fields </em>contained within it simply by setting the <strong>subform</strong>&#8216;s <strong>access attribute</strong> to &#8220;readOnly&#8221;!</p>
<p><span id="more-513"></span>
<p>The following table describes the four levels of restrictiveness (in XFA 2.8, from the highest level to the lowest) that can be imposed on <em>fields</em> using the access attribute, either directly on a <em>field</em> or by a parent subform:</p>
<table border="1" cellspacing="0" cellpadding="4" style="margin-bottom: 18px">
<tbody>
<tr>
<td><strong>Level</strong></td>
<td><strong>Access Value<br />
</strong></td>
<td><strong>Effect</strong></td>
</tr>
<tr>
<td>1</td>
<td><code>nonInteractive</code></td>
<td>Value can be loaded and calculations performed only upon form initialization.</td>
</tr>
<tr>
<td>2</td>
<td><code>protected</code></td>
<td>The user cannot change the value directly and the <em>field</em> does not participate in the tabbing sequence. The <em>field</em> does not generate any events.</td>
</tr>
<tr>
<td>3</td>
<td><code>readOnly</code></td>
<td>While the user may not change the value directly, it may be altered via scripts. The <em>field</em> still participates in the tabbing sequence and all events are generated except those related to direct user interaction.</td>
</tr>
<tr>
<td>4</td>
<td><code>open</code> (default)</td>
<td>The <em>field</em> is fully interactive and responds to direct user interaction.</td>
</tr>
</tbody>
</table>
<p>When a subform imposes restrictions on the <em>fields</em> it contains (meaning all <em>fields</em> within any level of nesting, not just immediate children), the inheritance on child <em>fields</em> and subforms follows that of the most restrictive parent imposition. For example, if a subform imposes access=&#8221;protected&#8221; and a child subform has access=&#8221;readOnly&#8221;, all of the inner subform&#8217;s children, including the inner subform itself, will effectively have a &#8220;protected&#8221; access level.</p>
<p>The explanations of the various access types in the table above are summarized. &#8220;Access Restrictions&#8221; on page 48 of the <a href="http://partners.adobe.com/public/developer/xml/index_arch.html#xfa_28">XFA 2.8 specification</a> has more precise, albeit more technical, explanations of each level of restrictiveness.</p>
<h2>Setting Access by Script</h2>
<p>Setting the access attribute of a <em>field</em> or subform by script is simple, both in JavaScript and FormCalc:</p>
<pre><code>// set access level to read-only:
FormObject.access = "readOnly";</code></pre>
<p>If you wanted to disable all <em>fields </em>in the entire form with a <strong>single line of script</strong>, you would simply set the root subform&#8217;s access attribute to something other than &#8220;open&#8221;, as appropriate:</p>
<pre><code>// if the root subform's name is "form1":
xfa.form.form1.access = "nonInteractive"</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2010/03/08/disabling-all-fields-within-subform/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Testing HTTP Submit Buttons</title>
		<link>http://forms.stefcameron.com/2009/12/16/testing-http-submit-buttons/</link>
		<comments>http://forms.stefcameron.com/2009/12/16/testing-http-submit-buttons/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 18:08:08 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/12/16/testing-http-submit-buttons/</guid>
		<description><![CDATA[While recently helping a few people with some issues related to HTTP submissions from XFA forms, I ended-up creating new Data Service that helps with testing HTTP Submit Buttons. The service is quite simple: It displays what you submit to it. Since Designer&#8217;s &#8220;PDF Preview&#8221; tab is actually an instance of Internet Explorer hosting a [...]]]></description>
			<content:encoded><![CDATA[<p>While recently helping a few people with some issues related to HTTP submissions from XFA forms, I ended-up creating new <a href="http://forms.stefcameron.com/data-services/">Data Service</a> that helps with <a href="http://forms.stefcameron.com/services/http-submit-test/">testing HTTP Submit Buttons</a>.</p>
<p>The service is quite simple: It displays what you submit to it. Since Designer&#8217;s &#8220;PDF Preview&#8221; tab is actually an instance of Internet Explorer hosting a PDF version of the form you&#8217;re previewing (a temporary PDF if your form is saved as an XDP or is new), the results are conveniently displayed within the tab itself after clicking on the submit button.</p>
<p>To use the service, simply use either an http submit button (or a regular button with its &#8220;Object palette &gt; Field tab &gt; Control Type property&#8221; set to &#8220;Submit&#8221;) and set its URL to:</p>
<p><a href="http://forms.stefcameron.com/services/http-submit-test/">http://forms.stefcameron.com/services/http-submit-test/</a></p>
<p>The idea is to use this service as a means to test/debug your forms before spending time writing the actual server code that will receive the data. You can also use it to ensure that you are submitting the correct data to a third-party service (for which you don&#8217;t control the server-side code).</p>
<p><span id="more-484"></span><br />
<h2>Choosing a Submit Format</h2>
<p>HTTP submissions can be made in various formats: XML, XDP, URL-encoded (HTTP post), and PDF. If you are using Reader instead of Acrobat, you will not be able to submit in PDF format unless you have enabled this ability using <a href="http://www.adobe.com/products/livecycle/readerextensions/">LC Reader Extensions</a>.</p>
<p>The most important difference amongst the formats is that <strong>repeating data sets cannot be submitted using URL-encoding</strong> (HTTP post). This is due to the way the data is submitted: In HTTP post directives, data is submitted in &#8220;name=value&#8221; pairs. Since repeating data sets involve hierarchy and duplicate data node names, only the last instance of the repeating set will be submitted.</p>
<p>To submit repeating data sets, you must choose either XML, XDP or PDF as the data format.</p>
<h2>Sample Form</h2>
<p>The following sample form demonstrates the use of the HTTP Submit Test service.</p>
<p><a href="http://forms.stefcameron.com/samples/data-binding/HttpSubmitTest.pdf">Download Sample [pdf]</a>
<p>The form has a typical address block as well as a table to demonstrate both static and repeating data sets. Use the submit buttons to try submitting in different formats (XML, XDP, PDF, URL-encoded). Notice how only the last table row is submitted when using the URL-encoded (&#8220;post&#8221;) submit button.
<p><strong>Minimum Sample Requirements:</strong> I created this sample using Designer 9.0 and Acrobat 9.2 however it should work fine back to Acrobat 7.0.5.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/12/16/testing-http-submit-buttons/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Multi-Selection List Schema Definition</title>
		<link>http://forms.stefcameron.com/2009/09/30/multi-selection-list-schema-definition/</link>
		<comments>http://forms.stefcameron.com/2009/09/30/multi-selection-list-schema-definition/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 14:07:02 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/09/30/multi-selection-list-box-schema-definition/</guid>
		<description><![CDATA[After spending some time, recently, showing you how to connect your form to a schema and highlighting Designer&#8217;s support for schema metadata, I thought I would round-off my current train of thought on schemas by tackling multi-selection listboxes. Since they store their selected data in &#60;value&#62; nodes, once you think about it, their schema definition [...]]]></description>
			<content:encoded><![CDATA[<p>After spending some time, recently, showing you how to <a href="http://forms.stefcameron.com/2009/08/03/connecting-to-a-schema/">connect your form to a schema</a> and highlighting Designer&#8217;s support for <a href="http://forms.stefcameron.com/2009/08/28/schema-metadata/">schema metadata</a>, I thought I would round-off my current train of thought on schemas by tackling multi-selection listboxes. Since they store their selected data in &lt;value&gt; nodes, once you think about it, their schema definition may not be obvious. When you&#8217;re working with XML data that isn&#8217;t governed by a schema and namespaces, it is perhaps easier to work with (i.e. accept) these &lt;value&gt; nodes however things change when you have a schema telling you how your data must be structured and scoped (with namespaces).</p>
<p><span id="more-449"></span><br />
<h2>How Lists Store Selected Items</h2>
<p>To better understand the challenges, let&#8217;s look at how list form objects store a multi-selection of values.</p>
<p>In the <strong>Form DOM</strong>, the list&#8217;s value actually contains XML rather than plain text. For example, say we have a multi-selection list named &#8220;ListBox1&#8243; (bound to a data element named &#8220;list1&#8243;) with items (&#8220;item1&#8243;, &#8220;item2&#8243;, &#8220;item3&#8243;). If the first two items were selected, the list&#8217;s value would look like this:</p>
<pre><code>&lt;value&gt;
    &lt;exData contentType="text/xml"&gt;
        &lt;list1&gt;
            &lt;value&gt;item1&lt;/value&gt;
            &lt;value&gt;item2&lt;/value&gt;
        &lt;/list1&gt;
    &lt;/exData&gt;
&lt;/value&gt;</code></pre>
<p>In <strong>script</strong>, this would translate to a newline (\n)-delimited string when the list&#8217;s value is accessed from its rawValue property:</p>
<pre><code>item1\nitem2</code></pre>
<p>In the <strong>Data DOM</strong>, the list&#8217;s value is stored in a series of repeating &lt;value&gt; nodes, much like the way it is stored in the Form DOM:</p>
<pre><code>&lt;list1&gt;
    &lt;value&gt;item1&lt;/value&gt;
    &lt;value&gt;item2&lt;/value&gt;
&lt;/list1&gt;</code></pre>
<h2>Adding the Schema</h2>
<p>A schema describes how XML should be structured. Given how lists store their selected items in data, a schema that includes a multi-selection list will need to allow for the element that defines the list to contain zero or more repeating &lt;value&gt; nodes. Unfortunately, this means modifying your schema, if you already have one. (I can think of at least one workaround to this which would involve script and a sibling, hidden text field bound to the element in your schema, as opposed to the list itself, in which you would store the selection, but I won&#8217;t get into that in this article.)</p>
<p>For example, <a href="http://forms.stefcameron.com/samples/data-binding/schema-multisellist/multiSelList-schema.xsd">this</a> is a schema that defines a &#8220;form1&#8243; root element that contains an element named &#8220;list1&#8243; that has a multi-selection list type (the way XFA expects it).</p>
<h3>Data Connection</h3>
<p>The problem with this structure is that once you connect your form to this schema, the Data View connection tree will interpret the list1 element as being a subform that contains a repeating node, &#8220;value&#8221;:</p>
<p><img src="http://forms.stefcameron.com/images/SchemaMultiSelList/SchemaMultiSelList-1.jpg"> </p>
<p>Because of this interpretation, you cannot simply drag &amp; drop the &#8220;list1&#8243; schema element into your form in order to get a multi-selection list. Instead, you&#8217;ll get a subform with a text field inside of it instead (only an element with a simple type restricted to an enumeration of values would be interpreted as a list). Furthermore, you cannot use the picker widget next to the &#8220;Object palette &gt; Binding tab &gt; Data Binding property&#8221; to assign &#8220;list1&#8243; to a listbox you have already dragged into your form from the Object Library palette because &#8220;list1&#8243; is viewed as a container (subform) and the form object you are attempting to bind is a field.</p>
<h3>Data Binding</h3>
<p>In order to bind the listbox to the &#8220;list1&#8243; schema element, you must manually type its binding expression into the &#8220;Object palette &gt; Binding tab &gt; Data Binding property&#8221;. For our simple use case, <strong>the binding is &#8220;list1&#8243;</strong>. Note that you don&#8217;t actually bind the repeating &#8220;value&#8221; element to anything and that the schema data connection tree will not actually indicate that the &#8220;list1&#8243; element is bound to a form object even though it now is (I&#8217;m guessing this is because it is expecting &#8220;list1&#8243; to be bound to a subform, not a field).</p>
<p>The result of binding the listbox to the &#8220;list1&#8243; schema element is that the Form DOM output changes slightly to include the proper namespace on the bound element within the field&#8217;s value:</p>
<pre><code>&lt;value&gt;
    &lt;exData contentType="text/xml"&gt;
        &lt;scof:list1 xmlns:scof="http://forms.stefcameron.com/ns/2009/"&gt;
            &lt;value&gt;item1&lt;/value&gt;
            &lt;value&gt;item2&lt;/value&gt;
        &lt;/scof:list1&gt;
    &lt;/exData&gt;
&lt;/value&gt;</code></pre>
<h2>Submitting Data</h2>
<p>As you might expect, given the structure of the listbox&#8217;s selection in the Form DOM above, the list&#8217;s selection data will be similar in the Data DOM (which is what would be submitted from the form as well):</p>
<pre><code>&lt;xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"&gt;
    &lt;scof:form1 xmlns:scof="http://forms.stefcameron.com/ns/2009/"&gt;
        &lt;scof:list1&gt;
            &lt;value&gt;item1&lt;/value&gt;
            &lt;value&gt;item2&lt;/value&gt;
        &lt;/scof:list1&gt;
    &lt;/scof:form1&gt;
&lt;/xfa:data&gt;</code></pre>
<p>The only problem with the data above is that it isn&#8217;t valid against the schema which specifies that the repeating &lt;value&gt; nodes inside the list1 element are part of the &#8220;scof&#8221; (target) namespace and should therefore look like &lt;scof:value&gt;.</p>
<h2>Submitting Namespaced Data</h2>
<p>In order to get the namespace into the repeating &lt;value&gt; nodes for the selected values, we have to use a workaround that involves a little script in the listbox&#8217;s Exit event (though the script could be triggered elsewhere, if you like):</p>
<pre><code>// JavaScript:

// schema namespace info
var nspace = "scof";
var nsUri = "http://forms.stefcameron.com/ns/2009/";

// get selection from list
var selection = this.rawValue.split("\n");

// build XML string for new selection in *Form DOM*
//  that includes the namespace in the &lt;value&gt;
//  nodes the outer &lt;listSelection&gt; node is
//  essentially irrelevant and will be discarded later
//  however it is required so that we can load its
//  content into the listbox's exData value node where
//  its value is set in the Form DOM
// this.dataNode.name gets the listbox's bound data
//  element name from the Data DOM which is required
//  in the XML
var newSelection = "&lt;listSelection&gt;\n&lt;" + nspace +
    ":" + this.dataNode.name + " xmlns:" + nspace +
    "='" + nsUri + "'&gt;";

// add selected items into the new selection -- take
//  note of the newline character at the beginning of
//  the string as it is critical to the XML loading
//  properly later on (it shouldn't be but it is...)
for (var i = 0; i &lt; selection.length; i++)
{
    newSelection += "\n&lt;" + nspace + ":value&gt;" +
        selection[i] + "&lt;/" + nspace + ":value&gt;";
}

// close the XML elements in the string
newSelection += "\n&lt;/" + nspace + ":" +
    this.dataNode.name + "&gt;\n&lt;/listSelection&gt;";

// load the new namespaced selection into the listbox's
//  exData value node, ignoring the root &lt;listSelection&gt;
//  node in the XML string
this.value.exData.loadXML(newSelection, true, true);</code></pre>
<p>The script above essentially builds an XML string equivalent in structure to that which is normally used to store the list&#8217;s selection in the Form DOM however it adds the necessary namespaces to the repeating &lt;ns:value&gt; nodes. This change is then replicated in the list1 data node in the Data DOM and the form&#8217;s exported data changes to this (which can be successfully validated against the schema we&#8217;re using):</p>
<pre><code>&lt;xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"&gt;
    &lt;scof:form1 xmlns:scof="http://forms.stefcameron.com/ns/2009/"&gt;
        &lt;scof:list1&gt;
            &lt;scof:value&gt;item1&lt;/scof:value&gt;
            &lt;scof:value&gt;item2&lt;/scof:value&gt;
        &lt;/scof:list1&gt;
    &lt;/scof:form1&gt;
&lt;/xfa:data&gt;</code></pre>
<h3><a name="warning"></a>Import Data Warning</h3>
<p>Unfortunately, I have to point-out a bug as it relates to exporting multi-selection values with namespaces (which you only get when you use the above workaround script): Importing data with namespaced &lt;ns:value&gt; nodes for multi-selection lists &#8212; though valid XML and valid against the schema &#8212; will fail in Acrobat 9.1.3 (I have not done any testing on previous versions). My testing has revealed that the form doesn&#8217;t render properly after the data merge. Importing namespaced data that does not have namespaced &lt;value&gt; nodes for multi-selection lists, however, does work fine (this is the default way data is exported, unless you use the script I outlined above).</p>
<h2>Sample Form</h2>
<p>I have built a sample form that demonstrates how multi-selection lists store their data in the Form DOM and Data DOM. The form also includes a checkbox which, when checked, will generate namespaced &lt;ns:value&gt; nodes instead of the default &lt;value&gt; nodes, using the workaround script in the list&#8217;s Exit event.</p>
<p>Download:</p>
<ul>
<li><a href="http://forms.stefcameron.com/samples/data-binding/schema-multisellist/SchemaMultiSelList.pdf">Form [pdf]</a>
<li><a href="http://forms.stefcameron.com/samples/data-binding/schema-multisellist/multiSelList-schema.xsd">Schema [xsd]</a>
<li><a href="http://forms.stefcameron.com/samples/data-binding/schema-multisellist/sampleData.xml">Sample Data [xml]</a>
<li><a href="http://forms.stefcameron.com/samples/data-binding/schema-multisellist/sampleData-ns.xml">Sample Data (namespaced) [xml]</a></li>
</ul>
<p><strong>Minimum Requirements:</strong> I designed this form using Designer ES2 Beta and Acrobat 9.1.3 however the form should work all the way back to Designer 7.1 and Acrobat 7.0.5.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/09/30/multi-selection-list-schema-definition/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Schema Metadata</title>
		<link>http://forms.stefcameron.com/2009/08/28/schema-metadata/</link>
		<comments>http://forms.stefcameron.com/2009/08/28/schema-metadata/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 03:48:35 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/08/28/schema-metadata/</guid>
		<description><![CDATA[My first tutorial on XML schemas explained how to connect your form to a schema however it did not show some of the Data View palette&#8217;s special features with respect to metadata in XML schemas. Using metadata based on a combination of the XML Schema appInfo and Dublin Core title and description elements, you can [...]]]></description>
			<content:encoded><![CDATA[<p>My first tutorial on XML schemas explained how to <a href="http://forms.stefcameron.com/2009/08/03/connecting-to-a-schema/">connect your form to a schema</a> however it did not show some of the Data View palette&#8217;s special features with respect to metadata in XML schemas.</p>
<p>Using metadata based on a combination of the XML Schema <a href="http://www.w3.org/TR/xmlschema-1/#element-appinfo">appInfo</a> and Dublin Core <a href="http://dublincore.org/documents/2008/01/14/dcmi-terms/#elements-title">title</a> and <a href="http://dublincore.org/documents/2008/01/14/dcmi-terms/#elements-description">description</a> elements, you can influence how the Data Connection Wizard creates fields you drag and drop from the data connection tree into your form. You can also direct the Data View palette to show some of this information in the Schema Data Connection Tree that it displays.</p>
<p><span id="more-428"></span>
<p>To demonstrate these features, I have <a href="http://forms.stefcameron.com/samples/data-binding/schema/movieRental-meta.xsd">extended</a> the <a href="http://forms.stefcameron.com/samples/data-binding/schema/movieRental.xsd">original</a> movie rental schema by adding metadata to its schema elements.<br />
<h2>Element Descriptions</h2>
<p>Sometimes a schema element&#8217;s purpose or use isn&#8217;t immediately clear based on its name and/or other properties. For example, just by seeing that the schema has a &#8220;customer.account&#8221; element wouldn&#8217;t necessarily tell you that this element should be empty for a new customer (since the system would generate a new account number upon submission of the customer&#8217;s first movie rental order). To clarify the use of this element, a description can be provided:</p>
<pre><code>&lt;xs:element name="account" type="xs:string" minOccurs="0"&gt;
    &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
            &lt;dc:description&gt;
                Customer's account number (empty if it's a new customer).
            &lt;/dc:description&gt;
        &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;</code></pre>
<p>Using the &#8220;Data View palette &gt; Palette menu button <img style="display: inline" src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-6.jpg"> &gt; &#8216;Show Both&#8217; command&#8221;, you can see the &lt;dc:description&gt; metadata associated with elements in your schema right within the Data Connection Tree:</p>
<p><img src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-1.jpg"> </p>
<p>Note that the description element must be part of the Dublin Core namespace (xmlns:dc=http://purl.org/dc/elements/1.1/) and must be contained within the XML Schema //annotation/appInfo elements in order for the Data Connection Wizard to detect it.</p>
<h2>Form Object Captions</h2>
<p>Often times schemas are defined at a corporate level because they can represent business rules and describe how data must be structured for its systems to be able to interpret it correctly. In those cases, it may be useful to also influence/dictate the labels that should be used to identify fields associated to certain schema elements. This can also be achieved with metadata by specifying title information:</p>
<pre><code>&lt;xs:element name="account" type="xs:string" minOccurs="0"&gt;
    &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
            &lt;dc:title&gt;Account #:&lt;/dc:title&gt;
        &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;</code></pre>
<p>Unlike descriptive metadata, this information is not displayed in the Data Connection Tree. Instead, it is used by the Data Connection Wizard when you drag and drop a schema element from the Data Connection Tree into your form.</p>
<p>Remember that, in the original schema (that didn&#8217;t have any metadata), generated fields would get captions similar to their schema element names. For example,&nbsp; dragging the &#8220;customer.account&#8221; field into a form would produce a field with &#8220;Account&#8221; as its caption. With the title metadata as defined above, the generated caption would instead be &#8220;Account #:&#8221;, as in the image below:</p>
<p><img src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-2.jpg"> </p>
<p>Note that the title element must be part of the Dublin Core namespace (xmlns:dc=http://purl.org/dc/elements/1.1/) and must be contained within the XML Schema //annotation/appInfo elements in order for the Data Connection Wizard to detect it.</p>
<h2>Extra Descriptive Information</h2>
<p>There&#8217;s one more way to provide information related to an element in a schema: Any text that is directly specified within an XML Schema //annotation/appInfo element (and is <strong>not</strong> further contained within a Dublin Core title or description element) is interpreted as extra &#8220;descriptive information&#8221;. When the element is dragged and dropped into a form, this text will be imported and associated with the generated field within a &lt;desc&gt; node, <em>provided the &#8220;Generate Descriptive Information&#8221; option is checked</em> in the &#8220;Data View palette &gt; Palette menu button <img style="display: inline" src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-6.jpg"> &gt; Options dialog&#8221;:</p>
<p><img src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-3.jpg"> </p>
<p>For example, the &#8220;returnBy&#8221; schema element is defined as follows:</p>
<pre><code>&lt;xs:element name="returnBy" type="xs:date"&gt;
    &lt;xs:annotation&gt;
        ...
        &lt;xs:appinfo&gt;
            Movies must be returned by 11:59pm on this date.
        &lt;/xs:appinfo&gt;
        &lt;xs:appinfo&gt;
            The late fee is is $0.50/hour.
        &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;</code></pre>
<p>Dragging and dropping that element into your form would produce the following field mark-up in the XML Source view:</p>
<pre><code>&lt;field name="returnBy"&gt;
    ...
    &lt;desc&gt;
        &lt;text name="Schema Annotation"&gt;
            Movies must be returned by 11:59pm on this date.
        &lt;/text&gt;
        &lt;text name="Schema Annotation 2"&gt;
            The late fee is is $0.50/hour.
        &lt;/text&gt;
    &lt;/desc&gt;
&lt;/field&gt;</code></pre>
<p>The Info palette could then be used to view the contents of all nodes inside the selected field&#8217;s &lt;desc&gt; node:</p>
<p><img src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-4.jpg"> </p>
<p>You can associate any number of extra &#8220;descriptive information&#8221; metadata elements to a single schema element definition. Each one would be imported as a separate &lt;text name=&#8221;Schema Annotation {x}&#8221;&gt; node within the associated form object&#8217;s &lt;desc&gt; node</p>
<p>This information can also be viewed within the Data View palette by choosing the &#8220;Palette menu button <img style="display: inline" src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-6.jpg"> &gt; &#8216;Show Info&#8217; command&#8221;. This will display the Info Panel in the bottom half of the palette. Selecting the &#8220;returnBy&#8221; schema element would then display the following information:</p>
<ul>
<li>XFA object name (returnBy);
<li>associated XFA object type (date/time field, since the schema defines its type as &#8220;date&#8221;);
<li>occurrence (single since it isn&#8217;t repeatable like the &#8220;movie&#8221; element, for example); and
<li>all other metadata identified as &#8220;descriptive info&#8221; associated to the element.</li>
</ul>
<p><img src="http://forms.stefcameron.com/images/SchemaMetadata/SchemaMetadata-5.jpg"> </p>
<h3>Script Access</h3>
<p>Finally, the descriptive information found in a form object&#8217;s //desc/text nodes can be retrieved via script by accessing its &#8220;desc&#8221; node property and iterating through all child nodes that are of type &#8220;text&#8221; and have &#8220;Schema Annotation&#8221; in their name.</p>
<p>For example, to output the two descriptions in the &#8220;returnBy&#8221; field (as defined above) to the <a href="http://forms.stefcameron.com/2006/05/05/debugging-scripts/">JavaScript Console</a> in Acrobat, you could use the following script:</p>
<pre><code>// JavaScript:
var descList = returnBy.desc.nodes;
for (var i = 0; i &lt; descList.length; i++)
{
    var item = descList.item(i);
    if (item.className == "text" &amp;&amp; item.name &amp;&amp;
            item.name.indexOf("Schema Annotation") == 0)
    {
        console.println(item.value);
    }
}</code></pre>
<p>With a little more effort, you could parse-out all sorts of useful information provided by this type of metadata in your schemas though, most of the time, that information can usually be expressed in real schema mark-up (e.g. list items and values).</p>
<h2>Combinations</h2>
<p>Of course, you aren&#8217;t limited to using a single type of metadata on a given schema element: You can combine them to provide the degree of information you require for any element. For example, the &#8220;customer.account&#8221; element specifies both title and description metadata while the &#8220;returnBy&#8221; element specifies title and descriptive information metadata.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/08/28/schema-metadata/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Connecting to a Schema</title>
		<link>http://forms.stefcameron.com/2009/08/03/connecting-to-a-schema/</link>
		<comments>http://forms.stefcameron.com/2009/08/03/connecting-to-a-schema/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 11:00:19 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[FormCalc]]></category>
		<category><![CDATA[Instance Manager]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/08/03/connecting-to-a-schema/</guid>
		<description><![CDATA[In previous tutorials, I have shown how to connect an XFA form to a database and a web service. Next on the list is the XML Schema (XSD). If you work in an enterprise setting, chances are you may have already had to deal with corporate data schemas that define how that data is structured. [...]]]></description>
			<content:encoded><![CDATA[<p>In previous tutorials, I have shown how to connect an XFA form to a <a href="http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/">database</a> and a <a href="http://forms.stefcameron.com/2007/05/21/connecting-to-a-web-service/">web service</a>. Next on the list is the <a href="http://www.w3.org/TR/xmlschema-1/">XML Schema</a> (XSD).</p>
<p>If you work in an enterprise setting, chances are you may have already had to deal with corporate data schemas that define how that data is structured. The goal, when connecting a form to a schema, is to ensure that the data consumed and output by the form adheres to a specific structure. Any fields bound to data nodes that aren&#8217;t inside the schema space are basically ignored at time of submission.</p>
<p><span id="more-410"></span>
<p>To help put things in context, I decided to define a schema for <a href="http://forms.stefcameron.com/samples/data-binding/schema/movieRental.xsd">movie rentals</a> to stay on the movie theme for the data I used in my other data connection tutorials.</p>
<p>Before we get started, I wanted to point-out that there are so many features related to schema handling and the Data View palette that I won&#8217;t be able to cover them all in a single tutorial. It would be information overload. Instead, I&#8217;ll try to point-out the basics along with a few interesting things that I think would be useful.</p>
<h2>Creating the Connection</h2>
<p><strong><font color="#008000">Right-click in the Data View palette and choose &#8220;New Data Connection&#8221;.</font></strong> In the first step, set the name for the connection (I set it to &#8220;SchemaConnection&#8221; so it&#8217;s easy to identify amongst any other connections that might be defined) and choose &#8220;XML Schema&#8221; as the type.</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-1.jpg"></p>
<p>Note that while you may have multiple ODBC and web service data connections, <strong>a form may be connected to only one schema</strong>. As of <a href="http://forms.stefcameron.com/2009/03/24/xfa-30-specification-available/">XFA 3.0</a> (Designer ES2, Acrobat/Reader 9.1), however, you can inject foreign data nodes into the Data DOM even if they aren&#8217;t in the schema, which may help if you need to get extra data into/out of your form (a topic for another post; for now, have a look at the new &#8220;File &gt; Form Properties &gt; Data Binding tab&#8221; in the <a href="http://blogs.adobe.com/mtg/2009/07/adobe_livecycle_es_next_beta_a.html">Designer ES2 Beta</a>). You can also merge schemas into a single, larger schema (&lt;import/&gt; nodes are supported which can make importing multiple schemas into a single one relatively easy).</p>
<p>The next and final steps are to choose the schema file and root element. Depending on how your schema is defined, you may have a choice of elements to use as the root. In the Movie Rental schema, there is only one root: &#8220;movieRental&#8221;.</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-2.jpg"></p>
<p>There are other options that let you embed the schema definition into your form (good if you don&#8217;t want to have to keep the schema file along with your form; otherwise, whenever you edit your form, you will need to ensure that the schema file is available) as well as specify XSLT files for incoming and outgoing data transformations (also a topic for another post).</p>
<h2>Data View Palette</h2>
<p>The initial view of the connection in the palette shows the data structure specified by the schema as represented in XFA. Each node in the schema gets an associated XFA object type depending on its description.</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-3.jpg"></p>
<p>For example:</p>
<ul>
<li>Complex types (such as {customer} and {movie}) are usually mapped to subforms since they are elements that contain child elements.
<li>Simple types (such as {customer.firstName} and {customer.prov}) are typically mapped to XFA fields. As you can see, the Schema Data Connection Wizard detected various types and assigned specific XFA fields to each data node: The {customer.prov} node is set to a drop down list because that element is defined as an enumeration of specific values in the schema while {movie.cost} is set to a decimal field because it&#8217;s type is &#8220;xs:decimal&#8221;.</li>
</ul>
<h2>Root Subform Name</h2>
<p>When the connection was created, there was a change to your form&#8217;s root subform name. Note how it has changed to <strong>movieRental</strong>:</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-4.jpg"></p>
<p>The name of the root subform is always the name of the root data element in the Data DOM. This ensures that data submitted from the form has the correct root element to match the schema and data merged into the form will be bound first by the root subform, then by child form objects.</p>
<h2>Inserting New Fields</h2>
<p>The Data View palette can be used to insert fields into your form. This makes it really easy to create new fields with the proper settings and bindings. You can customize how fields are created by choosing &#8220;Palette menu button <img style="display: inline" src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-5.jpg"> &gt; Options&#8221;:</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-6.jpg"></p>
<ul>
<li><strong>Generate Validation Scripts: </strong>If enabled, field Validate events will be generated for elements that have certain restraints defined in the schema.
<li><strong>Generate Descriptive Information:</strong> If enabled, particular forms of <a href="http://forms.stefcameron.com/2009/08/28/schema-metadata/">metadata in the schema</a> will be inserted into the field definitions in your form (more on this in another post).
<li><strong>Allow Tables to be Generated:</strong> If enabled, tables, rather than plain subforms, will be generated where appropriate.
<li><strong>Show Binding Properties Dialog Box:</strong> If enabled and you drag &amp; drop an element onto an existing field, a customization dialog will be displayed (more on this later).</li>
</ul>
<p>To insert a <em>new</em> field configured according to an element in the schema, just drag &amp; drop the element from the connection tree (in the Data View palette) into your form. You can add an entire group in a single operation by dragging a container element (e.g. {customer}). When a field in your form is bound to an element in the schema, a binding icon is displayed next to the element in the connection tree.</p>
<p><strong><font color="#008000">Start by dragging and dropping the {customer} element into your form.</font></strong> The result should be a new subform named &#8220;customer&#8221; containing 8 fields named according to the schema&#8217;s {customer} element and the elements it contains.</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-7.jpg"><br />New fields on the form.</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-8.jpg"><br />New structure in the hierarchy.</p>
<p>Notice how each leaf element in the connection now has a binding icon next to it in the connection tree (indicating that fields on the form are bound to those schema elements). The inserted fields were also customized according to their schema element counterparts. For example:</p>
<ul>
<li>All fields have appropriate data bindings (see &#8220;Object palette &gt; Bindings tab &gt; Data Binding property&#8221;).
<li>The {customer.prov} element became a drop down list which has a list of items, as well as a default value of &#8220;ON&#8221;, as specified in the schema.
<li>All new form objects have names that match their schema element names (though these could be altered, if better suited to any scripting requirements you may have, without affecting the data bindings).
<li>All new form objects have captions that are derived from their schema element names (e.g. the field bound to {customer.firstName} has a caption of &#8220;First Name&#8221;).</li>
</ul>
<p><strong><font color="#008000">Next, drag and drop the {movie} element from the connection into your form.</font></strong> This element is special because the schema specifies it may have multiple occurrences:</p>
<pre><code>&lt;xs:element
    name="movie"
    type="movieDef"
    minOccurs="1"
    maxOccurs="unbounded"/&gt;</code></pre>
<p>The result is a <strong>repeatable subform</strong>, as you can see by the Binding properties that were automatically set on the new &#8220;movie&#8221; subform (bound to movie[*] with Min Count set to 1 and no specified Max Count (unbounded)):</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-9.jpg"></p>
<p>(Note that if the properties on the &#8220;Object palette &gt; Binding tab&#8221; are partially disabled, it&#8217;s most likely because the movie subform is not inside a <em>flowed</em> container. Though it isn&#8217;t an XFA requirement, Designer requires it in order to enable the repeatable properties. We&#8217;ll fix this shortly.)</p>
<h2>Binding to Existing Fields</h2>
<p>There are two ways to bind an <em>existing</em> field to an element in the schema connection:</p>
<ol>
<li>Simply choose the element to which the field should bind by using the &#8220;Object palette &gt; Binding tab &gt; Data Binding property&#8221; pop-out menu (button to the right-hand side of the property) and selecting it from within the schema connection&#8217;s sub menu.
<li>Drag an element from the connection tree, in the Data View palette, and drop it on top of a field in your form. Doing so will &#8212; if it&#8217;s enabled &#8212; cause the <strong>Binding Properties Dialog Box</strong> to be displayed, giving you some options to further customize the existing field with information from the schema.</li>
</ol>
<h3><strong>Binding Properties Dialog Box</strong></h3>
<p><strong><font color="#008000">Add a new text field to your form.</font></strong> This will be for the {returnBy} schema element. Ensure that the &#8220;Show Binding Properties Dialog Box&#8221; option is checked in the &#8220;Data View palette &gt; Palette menu button &gt; Options&#8221; dialog. Now drag the {returnBy} element from the connection and drop it on top of the new text field.</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-10.jpg"></p>
<p>The above dialog will be displayed, giving you the option to update the following properties of the field on which the schema element was dropped:</p>
<ul>
<li><strong>Name:</strong> Updates the name of the field to match the name of the schema element (from &#8220;TextField1&#8243; to &#8220;returnBy&#8221;).
<li><strong>Caption:</strong> Updates the caption of the field to one derived from the schema (from &#8220;Text Field&#8221; to &#8220;Return By&#8221;).
<li><strong>Type:</strong> Updates the field&#8217;s object type to match the kind of data represented by the schema element (from text field to date/time field).
<li><strong>Type &gt; Default Value:</strong> Updates the field&#8217;s default value to that specified in the schema, if any (in the case of {returnBy}, the schema does not specify a default value).
<li><strong>Type &gt; Data Pattern:</strong> Updates the field&#8217;s patterns (display, edit, validate, data) according to the schema (in the case of {returnBy}, no pattern restrictions are specified in the schema, though a &#8220;date{YYYY-MM-DD}&#8221; data pattern will be set by default).</li>
</ul>
<p>Choose the &#8220;Update all related properties&#8221; option and click on the &#8220;OK&#8221; button. The text field you previously inserted will be updated to a date/time field with various properties matching the {returnBy} schema element&#8217;s specifications (as detailed above).</p>
<h2>Finishing Touches</h2>
<p>At this point, your form should look something like this (the positioning of the objects may differ depending on where you dropped them):</p>
<p><img src="http://forms.stefcameron.com/images/SchemaConnection/SchemaConnection-11.jpg"></p>
<p>Here are a few steps you can take to make things look a little nicer (in my opinion) as well as enable instances of the movie subform to be added for new movies to rent:</p>
<ol>
<li>Place the movie subform in a flowed subform so that <a href="http://forms.stefcameron.com/2006/11/11/instance-manager-object-reference/">multiple instances</a> can be added, flowed one after the other.
<li>Place an &#8220;add&#8221; button next to the movie subform to add instances as well as a &#8220;remove&#8221; button inside the movie subform to remove specific instances.
<li>Add an unbound decimal field that shows the running total cost for the movie rental order.
<li>Add script to the returnBy field to automatically set the date 30 days in the future.
<li>Add a submit button to submit the order.</li>
</ol>
<p>Following the steps above should yield a more functional movie rental form. The only thing missing is the ability to pull-in movies to choose from. For one thing, this would avoid having to specify the movie ID, title and cost when choosing a movie to rent. To accomplish this, you could connect the form to a movie <a href="http://forms.stefcameron.com/2006/10/12/displaying-all-records-from-an-odbc-data-connection/">database</a> (note that the database in the linked tutorial doesn&#8217;t have a &#8220;cost&#8221; column associated to a movie so you&#8217;ll have to add one) or, the <strong>more secure and recommended way</strong>, to a movie <a href="http://forms.stefcameron.com/2007/05/21/connecting-to-a-web-service/">web service</a>.</p>
<p><a href="http://forms.stefcameron.com/samples/data-binding/schema/ConnectingToSchema.pdf">Download Sample Form [pdf]</a></p>
<p><a href="http://forms.stefcameron.com/samples/data-binding/schema/movieRental.xsd">Download Schema [xsd]</a></p>
<p><a href="http://forms.stefcameron.com/samples/data-binding/schema/movieRental-Sample.xml">Download Sample Data [xml]</a></p>
<p><strong>Minimum Requirements:</strong> I designed this form using Designer ES2 Beta and Acrobat 9.1 however the principals should work all the way back to Designer 7.1 and Acrobat 7.0.5. There may be a few features lacking from the Data View palette if you go back that far but the concept of connecting the form to a schema remains the same.</p>
<p class="postUpdate"><strong>Aug 28, 2009</strong> &mdash; Added link to <a href="http://forms.stefcameron.com/2009/08/28/schema-metadata/">Schema Metadata</a> tutorial.</p>
<p class="postUpdate"><strong>Nov 4, 2009</strong> &mdash; Fixed a couple of syntax errors in the sample PDF form that were preventing the addition and removal of movie subform instances.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/08/03/connecting-to-a-schema/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
