<?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; Tables</title>
	<atom:link href="http://forms.stefcameron.com/category/tables/feed/" rel="self" type="application/rss+xml" />
	<link>http://forms.stefcameron.com</link>
	<description>Building intelligent forms using Adobe LiveCycle Designer</description>
	<lastBuildDate>Wed, 16 Feb 2011 22:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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>26</slash:comments>
		</item>
		<item>
		<title>PDF Forms Bible Review</title>
		<link>http://forms.stefcameron.com/2009/11/13/pdf-forms-bible-review/</link>
		<comments>http://forms.stefcameron.com/2009/11/13/pdf-forms-bible-review/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 23:13:18 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Instance Manager]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/11/13/pdf-forms-bible-review/</guid>
		<description><![CDATA[Last February, I announced the release of a new Designer book titled, &#8220;PDF Forms Using Acrobat and LiveCycle Designer Bible&#8221;. Over the past few months, I had the opportunity to review it and I thought I would share my comments, with respect to the second-half of the book, which deals with LiveCycle Designer ES and [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: left; margin-right: 15px" alt="PDF Forms Using Acrobat and LiveCycle Designer Bible" src="http://forms.stefcameron.com/images/pdfforms-book-cover.jpg">
<p>Last February, I announced the release of a <a href="http://forms.stefcameron.com/2009/02/05/new-book-acrobat-and-designer-bible/">new Designer book</a> titled, &#8220;PDF Forms Using Acrobat and LiveCycle Designer Bible&#8221;.</p>
<p>Over the past few months, I had the opportunity to review it and I thought I would share my comments, <strong>with respect to the second-half of the book</strong>, which deals with LiveCycle Designer ES and XFA forms, to help you decide if it would be a good book for you*. (The first-half deals with authoring PDF forms, a.k.a. AcroForms, in Acrobat and is beyond the scope of my blog.)</p>
<div style="clear: both; display: block">
<p><strong>Pros:</strong></p>
<ul>
<li>explains the licensing agreement involved when enabling forms for Reader using Acrobat&#8217;s &#8220;Extend Features in Adobe Reader&#8221; feature (p. 268) &#8212; this is a frequently-used feature however its governing licensing agreement, seldom understood, is explained here in &#8220;plain English&#8221;;
<li>presents and reasons through different design approaches for a particular solution, helping the reader make an informed decision on the best course of action;
<li>anything and everything you could possibly want to know is dealt with in some way;
<li>lots of important, time-saving insights in the inline &#8216;notes&#8217;;
<li>something for everyone from beginner to advanced;
<li>many cross-references between various topics, making it very easy to start in any chapter and still find all the information you need.</li>
</ul>
<p><strong>Caution:</strong></p>
<ul>
<li>risk of &#8220;information overload&#8221; &#8212; use this book as <em>reference</em> since it&#8217;s not a light read, though their goal is simply to present a myriad of options and let you pick the one that best suits your needs.</li>
</ul>
<p><strong>Overview of Topics Covered:</strong></p>
<ul>
<li>all about tables (from simple layouts to advanced);
<li>data merging with bindings;
<li>Designer user interface details and lots of tips and tricks for accelerating form layout tasks;
<li>working with static forms (with PDF backgrounds) and dynamic forms, highlighting the differences;
<li>great details on all sorts of pagination options;
<li>lots of detail on JavaScript and FormCalc, good scripting exercises with explanations, debugging tips, table with JavaScript and equivalent FormCalc functions to make it easy to script in either language if the other is more familiar to you;
<li>form deployment options;
<li>when and how to use data connections in your forms (XML, schema, database, web service) and setting data bindings;
<li>great overview of LiveCycle ES, its components (e.g. LC Forms, LC Reader Extensions, LC Rights Management, LC Content Services, etc.) and what they do.</li>
</ul>
<p>This book is available now on <a href="http://www.amazon.com/Forms-Using-Acrobatand-LiveCycle-Designer/dp/047040017X">Amazon.com</a> and <a href="http://www.wiley.com/WileyCDA/WileyTitle/productCd-047040017X.html">Wiley.com</a> and <a href="http://www.google.ca/search?q=pdf+forms+bible">elsewhere</a>.</p>
<p style="font-size: 9px">* Please note that these opinions are not necessarily those of Adobe Systems Incorporated.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/11/13/pdf-forms-bible-review/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating and Loading Data Nodes</title>
		<link>http://forms.stefcameron.com/2009/06/01/creating-and-loading-data-nodes/</link>
		<comments>http://forms.stefcameron.com/2009/06/01/creating-and-loading-data-nodes/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 11:00:03 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[CM]]></category>
		<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Instance Manager]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/06/01/creating-and-loading-data-nodes/</guid>
		<description><![CDATA[Have you ever needed to create data nodes in the Data DOM on-the-fly? How about a need to parse XML obtained from a web service data connection in order to find a value for some property? If that&#8217;s the case, then you&#8217;ll find-out how to do it in this article. Creating Data Nodes In a [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever needed to create data nodes in the Data DOM on-the-fly? How about a need to parse XML obtained from a <a href="http://forms.stefcameron.com/2009/03/23/pre-process-web-service-responses/">web service data connection</a> in order to find a value for some property? If that&#8217;s the case, then you&#8217;ll find-out how to do it in this article.</p>
<h2>Creating Data Nodes</h2>
<p>In a similar article, John Brinkman showed how to <a href="http://blogs.adobe.com/formfeed/2008/10/form_variables.html">create form variable nodes</a> at runtime however what&#8217;s not obvious about data nodes is that you don&#8217;t create them using
<p>a class name of your choice.</p>
<p>For example, say you wanted to create the following data node structure:</p>
<pre><code>&lt;custom&gt;
    &lt;message&gt;Hello World!&lt;/message&gt;
&lt;/custom&gt;</code></pre>
<p>&nbsp;</p>
<p><span id="more-372"></span></p>
<p>Given the following syntax for the createNode() function (see page 367 in the <a href="http://www.adobe.com/go/learn_lc_scriptingReference_82">LC Designer 8.2 Scripting Reference</a>):</p>
<pre><code>{model}.createNode(className [, name, namespace]);</code></pre>
<p>you might try the following, using &#8220;custom&#8221; as the class name for the first group/container node &lt;custom&gt;:</p>
<pre><code>var n = createNode("custom");</code></pre>
<p>Doing the above would generate an error stating that &#8220;custom&#8221; is an invalid node type.</p>
<p>The trick here is that only specific XFA class names are allowed, such as &#8220;text&#8221;, &#8220;decimal&#8221;, &#8220;integer&#8221;, etc., as well as two special types for data nodes: &#8220;dataGroup&#8221; and &#8220;dataValue&#8221;. When you need a data node that will <em>contain</em> other data nodes, you use the &#8220;dataGroup&#8221; class. When you need a data node to which you will <em>assign</em> a value, you use the &#8220;dataValue&#8221; node.</p>
<p>The JavaScript code to create the above XML structure then becomes:</p>
<pre><code>// &lt;custom&gt; data group to contain &lt;message&gt;
var c = xfa.datasets.createNode("dataGroup", "custom");
// &lt;message&gt; data value for "Hello World!"
var m = xfa.datasets.createNode("dataValue", "message");
// set value of data value node
m.value = "Hello World!";
// add &lt;message&gt; into &lt;custom&gt; data group node
c.nodes.append(m);
// print result to JavaScript Console (Ctrl + J in Acrobat)
console.println(c.saveXML("pretty"));

// output from above:

&lt;custom&gt;
    &lt;message&gt;Hello World!&lt;/message&gt;
&lt;/custom&gt;
</code></pre>
<p>Note that the createNode() function must be called on an object of type &#8220;model&#8221; and since we&#8217;re creating nodes in the Data DOM, we use the xfa.datasets object since it is a model object.</p>
<p>At this point, the &lt;custom&gt; node (and the nodes/values it contains) is <strong>not</strong> part of the Data DOM. To add it to the Data DOM so that it gets submitted with the rest of the form&#8217;s data, you would have to append it to a node <strong>inside</strong> the root subform (the top-most subform in the Hierarchy palette). For example, if your root subform&#8217;s name was &#8220;form1&#8243;, you would do the following to add the &lt;custom&gt; node to the form&#8217;s data:</p>
<pre><code>xfa.datasets.data.form1.nodes.append(c);</code></pre>
<p>This can be very useful. In fact, this technique is used in <a href="http://forms.stefcameron.com/category/cm/">Correspondence Management</a> letter template scripts to flag a selection list&#8217;s default selection as having been processed. Since the data merged into the list to print the letter based on the template may not match the default selection in the list, the scripts generate a special node directly in the Data DOM to indicate whether the list&#8217;s data value should be processed instead of its default selection (i.e. no need for a hidden checkbox field for each list, keeping the form/PDF file size down).</p>
<p>The &#8220;Custom Node Example&#8221; section in my <a href="http://forms.stefcameron.com/samples/data-binding/CreateLoadDataNode.pdf">sample form</a> demonstrates the above technique.</p>
<h2>Loading Data Nodes</h2>
<p>Another use for creating data nodes is they give you the ability to load existing XML in order to parse it without having to modify the Data DOM. If you create a new, orphaned (un-parented) data group node, you can use its loadXML() function to load an XML string into it, thereby giving you a handy XML node structure for parsing.</p>
<p>One example use of this would be in a form that retrieves various settings from a web service data connection where the structure of the returned data is determined by the input parameters (i.e. you have a single data connection which you can use to retrieve various data). You can return the XML data as a string and load it into a new data group node in order to parse-out the value you&#8217;re looking for without ever touching the Data DOM.</p>
<p>Another example would be an extension of my <a href="http://forms.stefcameron.com/2006/10/20/using-url-requests-in-pdf-forms/">URL Request</a> article. In this case, you could pass some XML data into your form via the URL request if your PDF form was available on a website. <font color="#ff0000"><strong>Warning:</strong> This is a not a secure method to pass data to your form.</font></p>
<p>Clicking the following link will load some movie data into the &#8220;Movies loadXML() Example&#8221; section of my sample form:</p>
<p><a href="http://forms.stefcameron.com/samples/data-binding/CreateLoadDataNodes.pdf?data=%3Cmovies%3E%3Cmovie%3E%3Ctitle%3ENacho%20Libre%3C%2Ftitle%3E%3Ccost%3E21.00%3C%2Fcost%3E%3CactorName%3EJack%20Black%3C%2FactorName%3E%3CcatName%3EComedy%3C%2FcatName%3E%3C%2Fmovie%3E%3Cmovie%3E%3Ctitle%3EMI%3AI%3C%2Ftitle%3E%3Ccost%3E20.00%3C%2Fcost%3E%3CactorName%3ETom%20Cruise%3C%2FactorName%3E%3CcatName%3EAction%3C%2FcatName%3E%3C%2Fmovie%3E%3C%2Fmovies%3E">CreateLoadDataNodes.pdf?data=%3Cmovies%3E%3Cmovie%3E%3Ctitle%3ENacho%20Libre%3C%2Ftitle%3E%3Ccost%3E21.00%3C%2Fcost%3E%3CactorName%3EJack%20Black%3C%2FactorName%3E%3CcatName%3EComedy%3C%2FcatName%3E%3C%2Fmovie%3E%3Cmovie%3E%3Ctitle%3EMI%3AI%3C%2Ftitle%3E%3Ccost%3E20.00%3C%2Fcost%3E%3CactorName%3ETom%20Cruise%3C%2FactorName%3E%3CcatName%3EAction%3C%2FcatName%3E%3C%2Fmovie%3E%3C%2Fmovies%3E</a></p>
<p>Finally, my sample form also has a handy &#8220;URI Encoding Tool&#8221; section which you can use to encode various strings to include in a website address (as above).</p>
<h2>Samples</h2>
<p><a href="http://forms.stefcameron.com/samples/data-binding/CreateLoadDataNodes.pdf">Download Sample [pdf]</a></p>
<p><strong>Minimum Sample Requirements:</strong> I created this sample using Designer 8.2 and Acrobat 9 however it should work fine back to Acrobat 7.0.5.</p>
<p>There is also a great example on creating data nodes on page 438 of the <a href="http://www.adobe.com/go/learn_lc_scriptingReference_82">LiveCycle Designer ES Scripting Reference for Designer 8.2</a> &#8212; an excellent XFA form scripting reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/06/01/creating-and-loading-data-nodes/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Expandable Table with Totals</title>
		<link>http://forms.stefcameron.com/2009/02/25/expandable-table-with-totals/</link>
		<comments>http://forms.stefcameron.com/2009/02/25/expandable-table-with-totals/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 12:00:27 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[FormCalc]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/02/25/expandable-table-with-totals/</guid>
		<description><![CDATA[It seems that calculating totals in an expandable table with a dynamic/repeatable row is a hot topic lately so I thought I would post a tutorial on how to build a simple table which represents a purchase order where you can add and remove line items and various totals are automatically calculated. Before we get [...]]]></description>
			<content:encoded><![CDATA[<p>It seems that calculating totals in an expandable table with a dynamic/repeatable row is a hot topic lately so I thought I would post a tutorial on how to build a <strong>simple</strong> table which represents a purchase order where you can add and remove line items and various totals are automatically calculated.</p>
<p>Before we get started, you&#8217;ll need Designer 7.1 and Acrobat/Reader 7.0.5 at minimum to run through this tutorial. <strong>I will be using Designer 8.2</strong> and Acrobat/Reader 9.0 to do the tutorial so it&#8217;s possible some of the UI may have changed slightly since the 7.1/7.05 versions.</p>
<p><span id="more-325"></span><br />
<h2>Creating the Table</h2>
<p>The first step is to drag a Table object from the Object Library palette&#8217;s Standard tab into your form. When you drop it, the <em>Insert Table</em> wizard appears. Set it to include 5 columns, 1 body row and header and footer rows:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-1.jpg"> </p>
<h2>Headers and Footers</h2>
<p>Double-click on the first &#8220;Header&#8221; cell and set the text/caption to &#8220;#&#8221;. This will be the dynamic index column. Set the remaining headers as follows: &#8220;Item&#8221;, &#8220;Quantity&#8221;, &#8220;Cost&#8221;, &#8220;Total&#8221;.</p>
<p>In the footer, we only need two cells: One with a caption that reads, &#8220;Grant Total:&#8221;, and the other for the calculated grand total. To start, select the first 4 footer cells by Ctrl-Clicking each one:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-2.jpg"> </p>
<p>Then, with the cells selected, click on the &#8220;Merge Table Cells&#8221; button in the Object palette (highlighted in yellow in the image below):</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-3.jpg"> </p>
<p>The 4 cells will merge into one and you can then double-click the text to change it to &#8220;Grand Total:&#8221;. While you&#8217;re editing the text, use the Paragraph palette to align it to the right.</p>
<p>We&#8217;re pretty much done with the header and footer row except for the grand total cell but we&#8217;ll come back to that after the body row has been defined.</p>
<h2>Body Row</h2>
<p>What we want for the body row is a text/read-only cell for the row number, a drop down list for selecting items, a numeric cell for the quantity, a numeric/read-only cell for the cost (which will be set depending on the selection in the item list) and a numeric/read-only cell for the calculated total (quantity * cost) for the row.</p>
<p>The first thing to do is to rename the &#8220;Row1&#8243; body row to &#8220;Item&#8221; and set it to repeat for each data item by selecting Row1 from the Hierarchy palette and setting its &#8220;Object palette &gt; Binding tab &gt; Name property&#8221; to &#8220;Item&#8221;, its &#8220;Default Binding&#8221; property to &#8220;Normal&#8221; and checking its &#8220;Repeat Row for Each Data Item&#8221; property to enable it to repeat so that the table can expand.</p>
<h3>Row Number Cell</h3>
<p>While this may sound complex, it&#8217;s actually quite easy to achieve. Since the Item body row will repeat, it will have an index and the index will be zero-based. This means our row number is simply the index of the cell&#8217;s parent (Item body row) + 1.</p>
<p>Drop a text field from the Object palette onto the first cell in the Item row. This will change the cell&#8217;s type to a text field. Set its name to &#8220;ItemIndex&#8221; (not just &#8220;index&#8221; because it&#8217;ll cause conflicts with the Item row&#8217;s index property), its &#8220;Object palette &gt; Binding tab &gt; Default Binding property&#8221; to &#8220;None&#8221; (since we don&#8217;t need the index in the submitted data &#8212; it&#8217;s just for show, after all) and its &#8220;Object palette &gt; Value tab &gt; Type property&#8221; to &#8220;Calculated &#8211; Read-Only&#8221;.</p>
<p>Finally, using the Script Editor, set its Calculate event to the following JavaScript code:</p>
<pre><code>(this.parent.index + 1) + ".";</code></pre>
<p>If we preview the form at this point, we&#8217;ll see that the first and only Item row has a row number of &#8220;1.&#8221;:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-4.jpg"> </p>
<h3>Item Name and Cost Cells</h3>
<p>The next cell is the item name. This will be a drop down list with a few items to choose from which have associated values that we&#8217;ll use to set the cost field depending on the selected item.</p>
<p>Drop a down down list from the Object Library onto the second cell in the Item row. Set its name to &#8220;ItemName&#8221; (not just &#8220;name&#8221; because it&#8217;ll cause conflicts with the Item row&#8217;s name property) and add some items to it using the Object palette&#8217;s Field tab. The following image shows that I&#8217;ve populated my list with 3 items:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-5.jpg"> </p>
<blockquote><p>An important thing to note here is that we did <strong>not</strong> associate values as costs to each item. It would&#8217;ve been convenient to store them like that however if we had, the item&#8217;s name would&#8217;ve shown-up as the cost in the submitted data which is not the intention. When data is submitted, we want the item&#8217;s name (e.g. &#8220;Helmet&#8221;) to show-up as the ItemName data.</p></blockquote>
<p>With the ItemName cell defined, we need to setup the Cost cell so that we can set its value to the value associated with the selected item.</p>
<p>Drop a numeric field from the Object Library onto the <strong>4th cell</strong> (the 3rd cell is for quantity) in the Item row. Set its name to &#8220;Cost&#8221;, its &#8220;Object Palette &gt; Binding tab &gt; Data Format property&#8221; to &#8220;Float&#8221;, its Value Type to &#8220;Read-Only&#8221; and its Display Pattern to &#8220;num{($zzzz9.99)}&#8221; (without the double-quotes).</p>
<p>Now set the following JavaScript code as the Change event for the <strong>ItemName</strong> drop down list:</p>
<pre><code>switch (xfa.event.newText)
{
    case "Helmet":
        Cost.rawValue = 45.00;
        break;

    case "Pedals":
        Cost.rawValue = 150.00;
        break;

    case "Wheel":
        Cost.rawValue = 225.00;
        break;

    default:
        // unknown item
        Cost.rawValue = 0;
        break;
}</code></pre>
<p>This simple script looks at the new selection in the ItemName list and sets the Cost field&#8217;s value accordingly.</p>
<p>At this point, we preview the form and choose &#8220;Pedals&#8221; as the item, the Cost cell will get a value of &#8220;150&#8243; which will be displayed as &#8220;$150.00&#8243; because of the display pattern we set on the Cost field earlier:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-6.jpg"> </p>
<h3>Quantity Cell</h3>
<p>With the ItemName and Cost cells defined, we can now define the Quantity cell. This one is quite simple: Drop a numeric field onto the 3rd cell in the Item row. Set its name to &#8220;Quantity&#8221; and its default value to 1.</p>
<h3>Total Cell</h3>
<p>The last cell in the Item row is the one what will show the total for that Item which is &#8220;Quantity * Cost&#8221;. This is another easy one: Drop a numeric field onto the 5th cell in the Item row. Set its name to &#8220;Total&#8221;, its Default Binding to &#8220;None&#8221; (no need to store calculated values in the data), its Value Type to &#8220;Calculated &#8211; Read-Only&#8221;, its Display Pattern to &#8220;num{($zzzz9.99)}&#8221; (without the double-quotes) and its Calculate event to the following <strong>FormCalc</strong> code:</p>
<pre><code>Quantity * Cost</code></pre>
<p>That&#8217;s it! FormCalc is great for spreadsheet-like calculations and in FormCalc, the &#8220;rawValue&#8221; property is implied so you don&#8217;t need to specify it like in JavaScript.</p>
<p>At this point, previewing our form and choosing &#8220;Pedals&#8221; as the item shows a calculated total of &#8220;$150.00&#8243; for that item:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-7.jpg"> </p>
<h2>Footer Grand Total Cell</h2>
<p>Now that the Item body row is complete, we just have a couple of things left to do. First, we need to setup the Grand Total field in the footer row which will display the grand total of the order. This field will be a numeric/read-only field which will calculate the sum of all Total fields in all Item rows that exist. This may sound complicated but once again, FormCalc makes this easy-as-pie.</p>
<p>Drop a numeric field onto the 5th (or 2nd or last) cell in the footer row. Set its name to &#8220;GrandTotal&#8221;, its Default Binding to &#8220;None&#8221; (no need to store calculated values in the data), its Value Type to &#8220;Calculated &#8211; Read-Only&#8221;, its Display Pattern to &#8220;num{($zzzz9.99)}&#8221; (without the double-quotes) and its Calculate event to the following <strong>FormCalc</strong> code:</p>
<pre><code>Sum(Item[*].Total)</code></pre>
<p>You&#8217;re probably wondering what the &#8220;[*]&#8221; notation means. Put simply, it&#8217;s like a wildcard for the index of the Item row and it tells the Sum function to get the value of the Total field in <strong>all instances </strong>of the Item row and calculate their sum.</p>
<p>At this point, if we preview our form and choose &#8220;Pedals&#8221; as the item, the total and grand total values are automatically calculated:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-8.jpg"> </p>
<h2>Adding/Removing Items</h2>
<p>Last but not least, we need a mechanism to add and remove items in the table. Since we had the Item row repeatable, this will be done using the <a href="http://forms.stefcameron.com/2006/11/11/instance-manager-object-reference/">Instance Manager</a> associated with the Item row.</p>
<p>To start, place two buttons on the form and name them &#8220;Add&#8221; and &#8220;Remove&#8221;. Set their captions to &#8220;Add&#8221; and &#8220;Remove&#8221; as well.</p>
<p>Using the Script Editor palette, set the Add button&#8217;s Click event to the following JavaScript code:</p>
<pre><code>Table1._Item.addInstance(0);</code></pre>
<p>This script will add a new instance of the Item row to the table. Now set the Remove button&#8217;s Click event to the following JavaScript code:</p>
<pre><code>if (Table1._Item.count &gt; 1)
    Table1._Item.removeInstance(Table1._Item.count - 1);</code></pre>
<p>This script will first make sure that there are at least 2 rows (since the minimum row count is 1) and if so, will remove the last row that was added to the table. Note the use of the <a href="http://forms.stefcameron.com/2006/05/18/instantiating-subforms-at-runtime/">underscore prefix</a> to access the Item row&#8217;s Instance Manager.</p>
<p>Previewing the form at this point will now allow you to add/remove rows and you&#8217;ll see that the totals are all being calculated automatically as you choose items and set quantities:</p>
<p><img src="http://forms.stefcameron.com/images/ExpandableTable/ExpandableTable-9.jpg"> </p>
<h2>Sample Form</h2>
<p>Here is the sample form for the tutorial. It&#8217;s the solution so try not to look at it until you&#8217;ve run through the tutorial on your own&#8230;</p>
<p><a href="http://forms.stefcameron.com/samples/tables/ExpandableTable.pdf">Download Sample [pdf]</a></p>
<p><strong>Sample Minimum Requirements:</strong> Designer 7.1/Acrobat 7.0.5</p>
<h2><a name="pageTotals"></a>Sample Form with Page Totals</h2>
<p>Reader Sandeep Goli asked an <a href="#comment-56711">interesting question</a>: How would one show a page total?</p>
<p>This can be done by adding first allowing the table&#8217;s content to break across pages by checking the &#8220;Object palette > Table tab > &#8216;Allow Page Breaks within Content&#8217; property&#8221;. The next step is to add another footer row to the table, located prior to the existing &#8220;FooterRow&#8221; row object (select the FooterRow row, duplicate it, rename it to &#8220;PageFooter&#8221;, rename the field inside to &#8220;PageTotal&#8221; and drag it up above the FooterRow object in the Hierarchy palette), and set it up to be included on subsequent pages as well as a the final page (rather than just the final page) using the &#8220;Object palette > Pagination tab > &#8216;Include Footer Row in Subsequent Pages&#8217; and &#8216;Include Footer Row in Final Page&#8217; properties&#8221;. This will cause the footer row to appear at the bottom of all pages, including the last page, as the table breaks across pages.</p>
<p>The final step in making this work is to set script in the new footer row&#8217;s Layout:Ready event. (If you duplicated the FooterRow, make sure you remove its Calculate script.) In this event, you can use APIs from the Layout Model which will let you determine the set of table &#8220;Item&#8221; rows that are on a given page &#8212; that being the page on which the PageTotal field was rendered:</p>
<pre><code>xfa.layout.page(object)</code></pre>
<p>will return the 1-based page number on which that object (field, subform, etc.) was rendered and</p>
<pre><code>xfa.layout.pageContent(zeroBasedPageIndex, type, 0)</code></pre>
<p>will return a list of all form objects of the specified type (a string, such as &#8216;subform&#8217;, &#8216;field&#8217;, &#8216;draw&#8217;, etc.) on the specified 0-based page index.</p>
<p>The following script finds all Item rows on the same page as the rendered PageTotal field, sums their Total child field values and sets that number as the PageTotal&#8217;s value:</p>
<pre><code>// get a list of all subforms rendered on the same page as this field
var pageSFList = xfa.layout.pageContent(xfa.layout.page(this) - 1, "subform", false);
var pageTotal = 0;
// for each subform named "Item", sum its "Total" field value
for (var i = 0; i &lt; pageSFList.length; i++)
{
    var sf = pageSFList.item(i);
    if (sf.name == "Item")
        pageTotal += sf.Total.rawValue;
}
// set this field's value to the sum of all Item rows on this page
this.rawValue = pageTotal;</code></pre>
<p><a href="http://forms.stefcameron.com/samples/tables/ExpandableTable-PageSum.pdf">Download Sample [pdf]</a><br /><a href="http://forms.stefcameron.com/samples/tables/ExpandableTable-PageSum-Data.xml">Download Sample Data [xml]</a></p>
<p><strong>Sample Minimum Requirements:</strong> Designer 8.0/Acrobat 8.0. This is due to bug fixes with table footer placement which are available only as of Acrobat 8.0.</p>
<h2><a name="removeThisRow"></a>Sample Form with Row Remove Button</h2>
<p>Reader Susila asked an <a href="#comment-60114">interesting question</a>: How do you remove a specific row using a &#8220;remove&#8221; button in the row to be removed?</p>
<p>This is done simply by inserting a column to the left of the ItemIndex column in the table and setting the cell&#8217;s type to a button. The button&#8217;s Click event is then set to remove the row to which it belongs.</p>
<p>The trick lies in writing the script in such a way that it automatically relates to (i.e. removes) the row instance to which it belongs. This is achieved by retrieving the instance index of the row to which it belongs and using that as the parameter supplied to the Item row <a href="http://forms.stefcameron.com/2006/11/11/instance-manager-object-reference/">Instance Manager</a>&#8216;s removeInstance([index]) method. The method expects a zero-based index and that&#8217;s what the index property gives you:</p>
<pre><code>// JavaScript:
this.parent.parent._Item.removeInstance(this.parent.index);</code></pre>
<p>The script above first accesses the button&#8217;s grand-parent (Table1). Then it gets the Instance Manager for the Item row and executes its removeInstance() method providing it with the index property value of its (the button&#8217;s) parent (Item row instance). By accessing parent objects, you ensure that you&#8217;re doing things with relation to the button that was clicked and, therefore, the row that contains the button.</p>
<p>Note that simply removing the row won&#8217;t necessarily update the ItemIndex field in other row instances that remain. If your form&#8217;s <a href="http://forms.stefcameron.com/2009/02/11/careful-with-form-compatibility-settings/">Target Version</a> is set to Acrobat/Reader 7.0.5, you will have to explicitly tell the form to <a href="http://forms.stefcameron.com/2006/05/20/add-recalculate/">re-execute calculations</a>. This issue was addressed in Acrobat 8.0+ so there&#8217;s no need to do this if your form targets a later version of Acrobat/Reader.</p>
<p><a href="http://forms.stefcameron.com/samples/tables/ExpandableTable-RemThisRow.pdf">Download Sample [pdf]</a></p>
<p><strong>Sample Minimum Requirements:</strong> Designer 7.1/Acrobat 7.0.5</p>
<h2>Further Improvements</h2>
<p>As I mentioned earlier, this is a <strong>simple </strong>dynamic table with a repeatable row. It demonstrates only the basics. You could enhance it further by including row shading options, validations, better formatting (font and paragraph), smarter add/remove buttons (e.g. put the remove button on the Item row in order to delete that specific row instead of always deleting from the end), put an insert button on the Item row in order to insert new items instead of always appending to the end of the list, etc.</p>
<p>For an advance sample, you should check-out the &#8220;Dynamic Interactive Purchase Order&#8221; sample that ships with Designer. Depending on how Designer was installed (either with Acrobat, with LiveCycle or standalone) and whether it was on Win 2k, XP or Vista, you should be able to find it in one of the following folders:</p>
<p align="left"><strong>C:\Program Files\Adobe\LiveCycle ES\Workbench ES\Designer ES\</strong><em>{version}</em>\EN\Samples\Forms\Purchase Order\Dynamic Interactive\Forms</p>
<p align="left"><strong>C:\Program Files\Adobe\LiveCycle Designer ES\</strong><em>{version}</em>\EN\Samples\Forms\Purchase Order\Dynamic Interactive\Forms</p>
<p align="left"><strong>C:\Program Files\Adobe\Acrobat\Designer\</strong><em>{version}</em>\EN\Samples\Forms\Purchase Order\Dynamic Interactive\Forms</p>
<p align="left">(Note that in Vista, &#8220;Program Files&#8221; changes to &#8220;Program Files (x86)&#8221;.)</p>
<p class="postUpdate"><strong>Updated Oct 2, 2009</strong> &#8212; Added <a href="#pageTotals">page totals</a> sample.</p>
<p class="postUpdate"><strong>Updated Oct 2, 2009</strong> &#8212; Added <a href="#removeThisRow">row remove button</a> sample.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/02/25/expandable-table-with-totals/feed/</wfw:commentRss>
		<slash:comments>107</slash:comments>
		</item>
		<item>
		<title>Recording of AUC eSeminar on LiveCycle Designer</title>
		<link>http://forms.stefcameron.com/2009/02/13/recording-of-auc-eseminar-on-livecycle-designer/</link>
		<comments>http://forms.stefcameron.com/2009/02/13/recording-of-auc-eseminar-on-livecycle-designer/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 18:29:11 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Instance Manager]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/02/13/recording-of-auc-eseminar-on-livecycle-designer/</guid>
		<description><![CDATA[The recording of the Acrobat User Community eSeminar on Advanced Forms and LiveCycle Designer by Easel Solution&#8217;s Angie Okamoto is now available for viewing. Angie demonstrates advanced concepts in creating dynamic forms with LC Designer and you can also see all of the Q&#38;A comment threads between the attendees and the team of specialists answering [...]]]></description>
			<content:encoded><![CDATA[<p>The recording of the <a href="http://www.acrobatusers.com/">Acrobat User Community</a> eSeminar on <a href="http://www.acrobatusers.com/events/1343/advanced-forms-and-livecycle-designer">Advanced Forms and LiveCycle Designer</a> by Easel Solution&#8217;s Angie Okamoto is now <a href="http://adobechats.adobe.acrobat.com/p85974540/">available for viewing</a>. Angie demonstrates advanced concepts in creating dynamic forms with LC Designer and you can also see all of the Q&amp;A comment threads between the attendees and the team of specialists answering the questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/02/13/recording-of-auc-eseminar-on-livecycle-designer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New book: Acrobat and Designer Bible</title>
		<link>http://forms.stefcameron.com/2009/02/05/new-book-acrobat-and-designer-bible/</link>
		<comments>http://forms.stefcameron.com/2009/02/05/new-book-acrobat-and-designer-bible/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 21:57:24 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Instance Manager]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/02/05/new-book-acrobat-and-designer-bible/</guid>
		<description><![CDATA[Angie Okamoto, Director of Enterprise Development at Easel Solutions, and Ted Padova, the &#34;PDF Guru&#34; and author of the &#34;Adobe Acrobat PDF Bible&#34; series, have published a new book titled, &#34;PDF Forms Using Acrobat and LiveCycle Designer Bible&#34;. I&#8217;m sure it&#8217;ll be a great reference! Their book is available now on Amazon.com and Wiley.com.]]></description>
			<content:encoded><![CDATA[<p><img style="float: left; margin-right: 15px" alt="PDF Forms Using Acrobat and LiveCycle Designer Bible" src="http://forms.stefcameron.com/images/pdfforms-book-cover.jpg" />
<p><a href="http://www.wiley.com/WileyCDA/Section/id-302475.html?query=Angie+Okamoto">Angie Okamoto</a>, Director of Enterprise Development at <a href="http://www.techedsolutions.com/">Easel Solutions</a>, and <a href="http://www.wiley.com/WileyCDA/Section/id-302475.html?query=Ted+Padova">Ted Padova</a>, the &quot;PDF Guru&quot; and author of the &quot;Adobe Acrobat PDF Bible&quot; series, have published a new book titled, &quot;<strong>PDF Forms Using Acrobat and LiveCycle Designer Bible</strong>&quot;. I&#8217;m sure it&#8217;ll be a great reference!</p>
<p>Their book is available now on <a href="http://www.amazon.com/Forms-Using-Acrobatand-LiveCycle-Designer/dp/047040017X">Amazon.com</a> and <a href="http://www.wiley.com/WileyCDA/WileyTitle/productCd-047040017X.html">Wiley.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/02/05/new-book-acrobat-and-designer-bible/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MAX 2008 Tutorial &#8211; Part 3 &#8211; Form Guide</title>
		<link>http://forms.stefcameron.com/2008/11/19/max-2008-tutorial-part3/</link>
		<comments>http://forms.stefcameron.com/2008/11/19/max-2008-tutorial-part3/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 13:00:53 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Form Guides]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2008/11/19/max-2008-tutorial-part-3-form-guide/</guid>
		<description><![CDATA[Welcome to the third and final part of a three-part post series tutorial on importing data into a form guide and a PDF. The first part covered the form design, the second part covered the Flex code and the third part will cover designing and debugging the form guide that will complete the solution. Form [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the third and final part of a three-part post series tutorial on importing data into a form guide and a PDF. The <a href="http://forms.stefcameron.com/2008/11/17/max-2008-tutorial-part1/">first part</a> covered the form design, the <a href="http://forms.stefcameron.com/2008/11/18/max-2008-tutorial-part2/">second part</a> covered the Flex code and the third part will cover designing and debugging the form guide that will complete the solution.</p>
<h2>Form Guide Layout</h2>
<p>The goal is to design a form guide which will provide two panels: one for user options and the other for results.</p>
<p>The first panel will expose the 4 fields inside the GuideObjects subform (which are only meant to be exposed in the form guide &#8212; hence why the GuideObjects subform has the Initialize script to hide it if the host isn&#8217;t &#8220;Flash&#8221;). The user will have the option to choose an actor and/or category for further filtering and will then click on the GetMovies button to execute the request on the <a href="http://forms.stefcameron.com/services/movies/?help=1">Movie Service</a>. When the requested XML is returned to the form guide, the GetMovies result handler will convert the XML into instances of MovieRow inside the Listing table.</p>
<p>The second panel will use a <strong>repeater layout</strong> to expose the Listing table&#8217;s contents within the form guide however this panel will only be accessible if the movie query returned 1 or more results.</p>
<p>Once the results are in, the user will then be able to switch (&#8220;flip&#8221;) to the PDF view which will show the Listing table in the form, from which the user could then print or archive the results.</p>
<p><span id="more-264"></span><br />
<h2>Designing the Form Guide</h2>
<p>Open your tutorial form in Designer and launch GuideBuilder (GB) by choosing the &#8220;Tools &gt; Create or Edit Form Guide&#8221; command. Switch to the &#8220;Customize Appearance&#8221; tab and choose &#8220;Save Styles&#8221;, saving them to a SWC file of your choice (usually in the same folder). It&#8217;s not mandatory to do this but if you don&#8217;t specify a file name here, GB will auto-generate a style SWC (which contains information about any style customizations you might apply) named according to the wrapper you choose (e.g. &#8220;ga.wrappers.CobaltStandard.swc&#8221; for the &#8220;Cobalt Standard&#8221; wrapper &#8212; not the most meaningful name for our solution).</p>
<p>Back to the &#8220;Edit Guide&#8221; tab, set the guide&#8217;s title to &#8220;MAX 2008 Movie Catalog Service&#8221; (double-click on the &#8220;New Guide&#8221; label to set it), the section&#8217;s title to &#8220;Movie Catalog&#8221; and the panel&#8217;s title to &#8220;Options&#8221;. Set the panel&#8217;s layout to &#8220;Two Column&#8221;.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-1.Png"></p>
<h3>Options Panel</h3>
<p>Click on the &#8220;Add or Bind Fields&#8221; button and drag the entire GuideObjects subform into the panel. You&#8217;ll see, in the &#8220;Panel Preview&#8221; pane on the lower-right, that objects in the panel are laid-out in two columns from left to right, top to bottom, according to the top-down order in which they appear in the panel. What we want is for the MatchCount field to show-up <em>below</em> the GetMovies button. To do this, insert a &#8220;Next Area&#8221; object (from the &#8220;Utility Objects&#8221; group at the top of the form tree) after all the objects in the panel and then drag the MatchCount field below it. The &#8220;Next Area&#8221; object causes a break in the layout algorithm, thereby forcing the following object onto the next row in the two-column layout.</p>
<p>To make the panel layout more pleasing, switch back to the &#8220;Set Properties&#8221; view and set the captions of the ActorList, CategoryList and MatchCount fields to be at the top and the width of both listboxes to be &#8220;100%&#8221;. Finally, override the MatchCount field&#8217;s caption (double-click on it) and set it to &#8220;Number of movies matching criteria:&#8221; (accept the warning about the caption binding being removed).</p>
<blockquote><p>One important form guide feature is the ability to display fields in different ways. In other words, if your field is a listbox, for example, you aren&#8217;t limited to displaying it as a traditional listbox. You could choose to display it as a series of checkboxes or radio buttons, for example, or you could create your own custom control using FlexBuilder.</p></blockquote>
<p>GB provides a checkbox control type which will suit our needs perfectly because while our listboxes are single-selection only, using checkboxes will allow the user to remove a previous selection which is important if they previously filtered by actor, for instance, and now they want to remove that filter.</p>
<p>For the ActorList and CategoryList fields, set their &#8220;Display field as a&#8221; property to &#8220;Check Boxes&#8221;.</p>
<p>At this point, the settings for the ActorList (and CategoryList) fields should look like this:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-2.Png"></p>
<p>and your form guide hierarchy should look like this:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-3.Png"></p>
<h3>Movie Listings Panel</h3>
<p>The second panel is a lot simpler since it just shows the Listing table&#8217;s contents and it doesn&#8217;t require as much settings.</p>
<p>Insert a second panel into the &#8220;Movie Catalog&#8221; section, give it a title of &#8220;Movie Listings&#8221; and set its layout to be &#8220;Repeater Grid&#8221;.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-4.Png"></p>
<p>The objects named &#8220;Repeater First Column&#8221; and &#8220;Repeater Second Column&#8221; don&#8217;t apply to this type of repeater panel however they do matter in other repeater layouts and are there for consistency (should you decide to change the repeater panel type). The &#8220;Trailer&#8221; object signifies that all objects placed after it, on this panel, will go <em>below</em> the grid as opposed to being part of the grid (this would be good for footer objects, if we had any).</p>
<p>Drag the MovieRow subform (table row) into the panel <strong>between</strong> the &#8220;Repeater First Column&#8221; and &#8220;Repeater Second Column&#8221; objects (drop the subform directly in between the two objects &#8212; if you miss, just drag each object back to where it&#8217;s supposed to go).</p>
<p>For each field you dragged-in, set its caption as follows: &#8220;Title&#8221;, &#8220;Actor&#8221;, &#8220;Category&#8221; and &#8220;Cost&#8221;. (You should see these changes in real-time in the Panel Preview pane.) Select the Title item and set its width to 150 (which means pixels in the form guide) to ensure the titles are completely visible and then set its &#8220;<strong>Allow field to repeat</strong>&#8221; property to indicate that it, and all associated fields, should be repeated within the grid layout. The items in the panel will then get a yellow outline indicating that they are repeating items.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-5.Png"></p>
<p>Now that we&#8217;ve set this up, I&#8217;ll follow-up on a comment I made in part 1 when we designed the Listing table and set the MovieRow to have 1 initial instance: There&#8217;s a <strong>bug in the Repeater Grid </strong>panel layout where the data entered into the fields in the grid will not be rendered (it&#8217;s there, you just can&#8217;t see it) unless there&#8217;s some data in the grid when the form guide is initialized. To work around the bug, we simply include an initial instance of the MovieRow and then the GetMovies result handler code simply removes the instance prior to populating the table with movie results (whether there are any or not).</p>
<p>The last step in setting-up this panel is to apply a <strong>Display Rule</strong> to indicate when the panel should be visible (accessible to the user) in the form guide. What we want to do is set the panel to be visible only if the MatchCount field&#8217;s value is greater than zero, meaning there&#8217;s at least one movie result from the query. To do this, you simply toggle the &#8220;Specify panel display rules&#8221; pane in the panel&#8217;s properties, choose &#8220;Use Display Rules&#8221;, add a rule, set MatchCount as the field, &#8220;greater than&#8221; as the condition and &#8220;0&#8243; as the value.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-6.Png"></p>
<h2>FormBridge XFO Fix</h2>
<p>Now that the form guide has been designed, the<br />
re&#8217;s just one more thing we need to do: Apply a small fix to the FormBridge code that brokers the communication between the form guide and the PDF at runtime. The FormBridge code is normally automatically injected into the PDF when it&#8217;s generated by the GB Preview functionality or by LiveCycle when the form is rendered as a form guide with the PDF however we need to use our own &#8220;fixed&#8221; version of the FormBridge code. Otherwise, when we flip to the PDF, <strong>there will be no data in the table.</strong></p>
<p>To do this, save your changes to the form guide and exit GB. Find the &#8220;Custom&#8221; pane in Designer&#8217;s Object Library and drag the &#8220;Form Bridge&#8221; object onto your form <strong>below</strong> the GuideObjects subform (where there are no objects on the page).</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-7.Png"></p>
<p>It shows-up as a hairline selection on the page and in the hierarchy looks like this:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-8.Png"></p>
<p>Select the &#8220;ContainerFoundation_JS&#8221; script object and open the Script Editor to edit the script. Find the two instances of &#8220;saveXML()&#8221; (lines 316 and 631) using the Find dialog (Ctrl + F) and change them from</p>
<pre><code>saveXML().replace(/\n/g, "");</code></pre>
<p>to</p>
<pre><code>saveXML();</code></pre>
<p>Do not remove/change any of the code that comes before it on the same line. This fix ensures that the format of the data going across the line is correct.</p>
<p>With the FormBridge object in our form, GB Preview and LiveCycle will not inject their version into the PDF. The only draw-back from this approach is that if the FormBridge code changes, you&#8217;ll have to manually update it in your form as opposed to automatically getting the new version when you preview with GB or render your form with LiveCycle.</p>
<p>This bug should be fixed in a future release and so the workaround in the FormBridge code will eventually no longer be needed.</p>
<h2>Flash Log and Debug Players (Optional)</h2>
<p>You may have noticed some &#8220;trace()&#8221; statements in the code we set on the ActorList, CategoryList and GetMovies objects in part 2. This is a handy way to get a read on what&#8217;s going on (i.e. debugging) inside the form guide at runtime if you aren&#8217;t using FlexBuilder to debug it (which we&#8217;re trying to avoid in this tutorial). It&#8217;s a lot like using &#8220;console.println()&#8221; to output information to Acrobat&#8217;s JavaScript Console.</p>
<p>If you want to see trace statement outputs (it&#8217;s not necessary but it could be handy), you need to look at your flashlog.txt file which is auto-generated by the <strong>debug</strong> version of the Flash Player. These are normally called &#8220;debug players&#8221; or &#8220;content debuggers&#8221; and are <a href="http://www.adobe.com/support/flashplayer/downloads.html">downloadable here</a>. To ensure that you have a debug player, you can hit <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19245&amp;sliceId=1">this page</a> which will tell you what version and type of Flash Player your browser is using.</p>
<p>Once you&#8217;ve installed a debug player, you&#8217;ll need to configure your system to enable the flashlog.txt file which will be located here, once enabled: C:\Documents and Settings\<em>user_name</em>\Application Data\Macromedia\Flash Player\Logs\flashlog.txt (XP) or C:\Users\<em>user_name</em>\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt (Vista).</p>
<p>The <a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&amp;file=logging_125_04.html">debugger configuration page</a> details where to place the mm.cfg file and what to put in it in order to enable output to the flashlog.txt file. For example, if you&#8217;re running XP, you would create a new mm.cfg file in your &#8220;C:\Documents and Settings\<em>user_name</em>\&#8221; folder and you would put the following lines inside to enable error reporting and trace logging (i.e. output to the flashlog.txt file):</p>
<pre><code>TraceOutputFileEnable=1
ErrorReportingEnable=1</code></pre>
<h2>Running the Solution</h2>
<p>Now that the form guide is designed, we&#8217;re ready to run our solution: Launch GB again and this time, choose the Preview tab, select &#8220;Include PDF Preview&#8221; (to ensure that a PDF is included, otherwise you won&#8217;t be able to flip to it to see the results) and click on the Preview button.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-9.Png"></p>
<p>The resulting form guide should look like this (with the pre-loaded actor and category lists):</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-10.Png"></p>
<p>When you click on the &#8220;Get Movies&#8221; button, the button will become temporarily disabled and then, assuming your query returned movies, the count should be updated and the &#8220;Movie Listing&#8221; panel should appear in the left toggle bar:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-11.Png"></p>
<p>Now click on the &#8220;Movie Listing&#8221; panel to see the results in the form guide:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-12.Png"></p>
<p>Finally, click on the &#8220;Show PDF&#8221; icon in the toolbar at the top-right to see the results (i.e. imported Movie Service data) in the PDF:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part3-13.Png"></p>
<p>Cool? I think so! And the cherry on top is that this even works with the free Reader! Users don&#8217;t need Acrobat in order for the data to go back and forth between the form guide and the PDF.</p>
<h2>Solution to Part 3</h2>
<p>Try not to peek at this before you attempt to build the form guide on your own…</p>
<p><a href="http://forms.stefcameron.com/samples/max2008/Max2008-MovieCatalog-Part3.zip">Download Part 3 [zip]</a></p>
<p><strong>Minimum Requirements:</strong> Designer 8.2.1 SP1, GuideBuilder 8.2.1 SP1, Reader 9.0.</p>
<p><strong>Note:</strong> If you decide to deploy this sample to LiveCycle (e.g. using FormsIVS), you&#8217;ll also need to deploy the styles SWC you created earlier. The form guide will not render without it.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2008/11/19/max-2008-tutorial-part3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MAX 2008 Tutorial &#8211; Part 2 &#8211; Flex Code</title>
		<link>http://forms.stefcameron.com/2008/11/18/max-2008-tutorial-part2/</link>
		<comments>http://forms.stefcameron.com/2008/11/18/max-2008-tutorial-part2/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 13:00:14 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Form Guides]]></category>
		<category><![CDATA[Instance Manager]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2008/11/18/max-2008-tutorial-part-2-flex-code/</guid>
		<description><![CDATA[Welcome to the second in a three-part post series on importing data into a form guide (and, by extension, a PDF form). In the first part, we designed the XFA form that will provide us with the print/archive view of the movies retrieved from the Movie Service. The second part will focus on the special [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the second in a three-part post series on importing data into a form guide (and, by extension, a PDF form). In the <a href="http://forms.stefcameron.com/2008/11/17/max-2008-tutorial-part1/">first part</a>, we designed the XFA form that will provide us with the print/archive view of the movies retrieved from the <a href="http://forms.stefcameron.com/services/movies/?help=1">Movie Service</a>. The second part will focus on the special Flex code we will need to include in the form which will ultimately be executed by Flash when it runs in the form guide which we&#8217;ll design in part 3.</p>
<h2>Flex Code in XFA Forms</h2>
<p>The key to today&#8217;s tutorial is understanding when and where the script you write in an XFA form (JavaScript or FormCalc) is compiled or interpreted.</p>
<p><span id="more-246"></span>
<p>For starters, form guides don&#8217;t support the FormCalc language so that just isn&#8217;t an option.</p>
<p>JavaScript, on the other hand, has the nice property of looking a lot like ActionScript. In fact, the two languages have enough similarities that with very little modification, any JavaScript you write in an XFA form can be converted into ActionScript which runs in a Flex form guide (in the Flash Player).</p>
<p>Normally, when you write JavaScript code in your forms and you run the form in Acrobat, the script isn&#8217;t compiled when the XFA form is converted into the PDF file format and it&#8217;s only interpreted when the interpreter attempts to execute it (i.e. if there&#8217;s a syntax error somewhere in your script and you never run that code, you&#8217;ll never know about the error). When you generate a form guide based on your form, however, your JavaScript is actually <strong>compiled by</strong> the <strong>Flex </strong>compiler that generates the SWC (Flash Library) which defines your form guide.</p>
<blockquote><p><span style="font-weight:bold;color:red">Warning: </span>Script object code seems to be loaded and interpreted by Acrobat in one shot, instead of on a per-access basis as in form object event scripts, and any syntax errors anywhere in the script object will cause all of the script in the script object to basically be ignored. If you have functions defined in a script object and you know you&#8217;re calling a function properly but you keep getting a &#8220;function is not defined&#8221; error, use the Script Editor&#8217;s Syntax Checker tool &#8212; you&#8217;ll probably find a syntax error somewhere. After you fix it, you should be able to access your script object functions.</p>
<p> It also appears that Acrobat/Reader 9.0 may now be attempting to parse (but not execute) <em>all</em> scripts on form load which may produce syntax errors in the JavaScript Console due to the differences between JavaScript and ActionScript syntax however in my experience so far, I haven&#8217;t hit a situation where my JavaScript stops executing because of this. Nonetheless, if you&#8217;re seeing strange behaviour, it might be a good idea to check the console to make sure things are running smoothly.</p></blockquote>
<p>What you might not have realized is that if you know that a particular portion of script will only be executed within the context of a form guide, you can actually <strong>write Flex code in your XFA form! </strong>When you generate the form guide (either by previewing using GuideBuilder or by rendering the form as a form guide via <a href="http://www.adobe.com/products/livecycle/forms/">LiveCycle Forms</a>), your Flex code will be compiled as any other Flex code would be and it&#8217;ll be executed in the same way.</p>
<p>That opens-up a world of possibilities and the one we&#8217;re going to explore in this tutorial is the use of the <a href="http://livedocs.adobe.com/flex/3/langref/mx/rpc/http/mxml/HTTPService.html">mx.rpc.http.HTTPService</a> class to fetch data from the Movie Service and insert the results into the Listing table within the form guide, thereby causing the data to be inserted into the Listing table within the PDF form when the user switches from the form guide to the PDF.</p>
<h2>XFA Host Name = Flash</h2>
<p>You might recall, in yesterday&#8217;s tutorial, that I talked about the <strong>xfa.host.name</strong> property returning &#8220;Flash&#8221; when your XFA code is executing within the context of a form guide (it returns &#8220;Acrobat&#8221; when its executed within the PDF because the form&#8217;s &#8220;host&#8221; is &#8220;Acrobat&#8221;).</p>
<p>This is the indicator we&#8217;ll use to &#8220;protect&#8221; the Flex code we&#8217;re going to write to make sure that it&#8217;s not executed within the PDF:</p>
<pre><code>if (xfa.host.name == "Flash")
{
    // do some cool stuff in Flex/ActionScript
}</code></pre>
<blockquote><p>Note that the <strong>XFA model in a form guide</strong> works just the same as it does within the PDF with the exception that the form guide environment only supports a <a href="http://help.adobe.com/en_US/livecycle/8.2/fgscriptsupport.pdf">subset of XFA functionality</a> (less than in the PDF but more than in HTML).</p></blockquote>
<h2>Our Own HTTPService</h2>
<p>Since there will 3 requests made to the Movie Service, one for the actor list, one for the category list and another for the movie listings resulting from the chosen actor and/or category (if any), the first step to take is to create some reusable code within our form that makes use of the HTTPService object.</p>
<p>Open the form you designed yesterday and add a new script object by right-clicking on the root subform (&#8220;movieList&#8221;) and choosing the &#8220;Insert Script Object&#8221; command.</p>
<p>Name your script object &#8220;FlexHttpService&#8221; and paste the code from <a href="http://forms.stefcameron.com/samples/max2008/Max2008-FlexHttpService.txt">this text file</a> into the script object.</p>
<p>You&#8217;ll notice that there are some statements in this script that aren&#8217;t regular JavaScript (namely the &#8220;import&#8221; statements to get access to the HTTPService and its result and fault event classes as well as the typing of variables like &#8220;service:HTTPService&#8221;). That&#8217;s because it&#8217;s ActionScript!</p>
<p>I&#8217;m assuming you know enough about Flex to be able to understand what&#8217;s going on but the gist of it is that the script object&#8217;s send() function takes a URL (to the Movie Service) and two functions, the first called when the request is successful and the second called if the request fails. If the request is successful, the result handler function is called with an XML variable as its parameter. This XML variable contains the movie listing we want to insert into the Listing table.</p>
<p>The FlexHttpService.send() function will be the reusable piece of code that we&#8217;ll use in the two listboxes and the button, each providing its own URL and result handlers.</p>
<blockquote><p>It&#8217;s important to note that the actual result and fault handlers given to the HTTPService object instance are <strong>inline functions</strong>. This is essential since the call to HTTPService.send() is <strong>asynchronous</strong>. When the result comes back (later), context will be lost and the service won&#8217;t be able to find a function you defined in the FlexHttpService script object. Therefore, the handlers must be inline.</p></blockquote>
<h2>ActorList Initialize Script</h2>
<p>With the FlexHttpService defined, it&#8217;s easier to write the rest of the code to fetch the <a href="http://forms.stefcameron.com/services/movies/?movie=0&amp;actor=0">list of actors</a>.</p>
<p>We want the list of actors to be retrieved when the form guide initializes so we&#8217;ll put this script in the Initialize event of the ActorList field. In the result handler, we&#8217;ll simply iterate through the items in the XML object returned and, for each actor, add his/her name and ID as an item into the ActorList field in the form guide.</p>
<p>Note that accessing the ActorList field in the form guide <strong>within the result handler</strong>, which is out-of-context at this point, is done by using the full SOM expression to the field, starting with <strong>xfa.form</strong> (accessing the Form DOM), followed by the root subform name (&#8220;movieList&#8221;), followed by the path to the ActorList field.</p>
<p>Edit the ActorList field&#8217;s Initialize event and paste the code from <a href="http://forms.stefcameron.com/samples/max2008/Max2008-ActorListInit.txt">this text file</a> into it.</p>
<p>Basically, we first clear any existing list items and call the Movie Service with the appropriate URL. In the result handler, we add items into the ActorList and then enable the list so that the user can make a selection (we don&#8217;t want the list accessible until the items have been loaded).</p>
<h2>CategoryList Initialize Script</h2>
<p>The CategoryList field is much the same as the ActorList field however it&#8217;ll fetch the <a href="http://forms.stefcameron.com/services/movies/?movie=0&amp;category=0">list of categories</a>.</p>
<p>Edit the CategoryList field&#8217;s Initialize event and paste the code from <a href="http://forms.stefcameron.com/samples/max2008/Max2008-CategoryListInit.txt">this text file</a> into it.</p>
<h2>GetMovies Click Script</h2>
<p>Finally, we just need to set the Click event script on the GetMovies button that will fetch the movies requested by the user (optionally filtering on actor and/or category).</p>
<p>This script is essentially the same as the first two however it&#8217;s a little more complex since the Listing table must be retrieved and then new instances of the MovieRow must be <a href="http://forms.stefcameron.com/2006/11/11/instance-manager-object-reference/">added</a> and their fields (Title, Actor, Category and Cost) populated with data from each movie returned from the service. Additionally, the button is disabled once its clicked and only re-enabled when the result or fault handler is called to prevent the user from clicking multiple times while a request is pending (since HTTPService.send() is asynchronous) and the MatchCount field is populated with the number of rows added to the Listing table (this will be important when we design the form guide in part 3).</p>
<p>Edit the GetMovies button&#8217;s Click event and paste the code from <a href="http://forms.stefcameron.com/samples/max2008/Max2008-GetMoviesClick.txt">this text file</a> into it.</p>
<h2>Solution to Part 2</h2>
<p>Try not to peek at this before you attempt to build the form on your own&#8230;</p>
<p><a href="http://forms.stefcameron.com/samples/max2008/Max2008-MovieCatalog-Part2.zip">Download Part 2 [zip]</a></p>
<p><strong>Minimum Requirements:</strong> The form should work back to Designer 8.0 however it was designed with Designer 8.2.1 SP1.</p>
<p class="postUpdate"><strong>Updated:</strong> November 22, 2008</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2008/11/18/max-2008-tutorial-part2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MAX 2008 Tutorial &#8211; Part 1 &#8211; Designing the Form</title>
		<link>http://forms.stefcameron.com/2008/11/17/max-2008-tutorial-part1/</link>
		<comments>http://forms.stefcameron.com/2008/11/17/max-2008-tutorial-part1/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 13:00:05 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Data Binding]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XFA]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2008/11/17/max-2008-tutorial-part-1-designing-the-form/</guid>
		<description><![CDATA[This is the first part in a multi-part post series for Adobe MAX 2008 designed to show you how extend a form guide to import data from a website without using FlexBuilder. If you haven&#8217;t seen it already, I recommend you have a look at the demo on last Friday&#8217;s tutorial preview post to get [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first part in a multi-part post series for <a href="http://max.adobe.com/">Adobe MAX 2008</a> designed to show you how extend a form guide to import data from a website <strong>without using FlexBuilder</strong>. If you haven&#8217;t seen it already, I recommend you have a look at the demo on last Friday&#8217;s <a href="http://forms.stefcameron.com/08/11/14/max-2008-tutorial-preview/">tutorial preview</a> post to get a sense of what we&#8217;re going to be building. In this first part, we will build the form necessary to provide the print/archive capabilities for the Movie Catalog.</p>
<p>Throughout the tutorial, I will assume that you&#8217;ve used Designer already and you know about things like flowed vs positioned subforms. I will also assume that you&#8217;re familiar with Guide Builder&#8217;s interface for designing Form Guides.</p>
<h2>Software Requirements</h2>
<p>Before we get started, make sure you&#8217;re using Designer 8.2.1 SP1 and Guide Builder 8.2.1 SP1. You can download an evaluation version of Designer and Guide Builder when you download the <a href="http://www.adobe.com/products/acrobatpro/tryout.html">Acrobat 9.0 Pro trial</a>. If you haven&#8217;t installed SP1 yet, you can download it from <a href="http://www.adobe.com/support/products/enterprise/200810kcs_livecyclees_8.html">here</a> (note that you only need to install the Designer SP1 update &#8212; you don&#8217;t need Workbench or even LiveCycle ES to run through this tutorial).</p>
<p>If you already have Designer but you don&#8217;t have Acrobat, you can use <a href="http://www.adobe.com/products/acrobat/readstep2.html">Reader 9.0</a> to go through the tutorial.</p>
<p><span id="more-238"></span><br />
<h2>Schema Data Connection</h2>
<p>The first step is to connect the form to a schema which we can <a href="http://forms.stefcameron.com/services/movies/?schema=movie">obtain</a> from the <a href="http://forms.stefcameron.com/services/movies/?help=1">Movie Service</a>:</p>
<pre><code>&lt;movieList&gt;
&nbsp;&nbsp;&nbsp; &lt;movie&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;movieId/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;title/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cost/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;actorName/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;catName/&gt;
&nbsp;&nbsp;&nbsp; &lt;/movie&gt;
&nbsp;&nbsp;&nbsp; &lt;movie&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;movieId/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;title/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cost/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;actorName/&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;catName/&gt;
&nbsp;&nbsp;&nbsp; &lt;/movie&gt;
&lt;/movieList&gt;</code></pre>
<p>Save this structure to an XML file named &#8220;movieCatalog-schema.xml&#8221; somewhere where you can reference it later from your form in Designer. (It&#8217;s important that you save it as-is with the duplicated &lt;movie&gt; element since this will indicate to the Data Connection Wizard that the &lt;movie&gt; element is repeatable.)</p>
<p>Create a new blank form in Designer and then create a new data connection using the Data Connection Wizard available from the Data View palette&#8217;s menu button. On the first page, set the name to &#8220;MovieCatalogDC&#8221; and choose &#8220;Sample XML File&#8221;:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-1.Png"> </p>
<p>On the next page, choose the &#8220;movieCatalog-schema.xml&#8221; file you saved earlier and click &#8220;Finish&#8221;. You should now have a schema data connection in your form (note that Designer inferred the possible structure of the schema based on the sample XML file we provided for the data connection):</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-2.Png"> </p>
<p>This data connection will help us set the correct bindings later.</p>
<h2>Page Header</h2>
<p>Next we&#8217;ll create a simple header for the form by adding a text object to the Master Page. Switch to the Master Pages tab and drag a text object onto it. Place it at the top-left and set the text to &#8220;MAX 2008 Movie Catalog&#8221;.</p>
<p>To make sure that what we&#8217;ll put on the body pages (in the Design View) doesn&#8217;t show-up over-top our header, make sure that the content area starts below the header text object:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-3.Png"> </p>
<h2>Movie Listing Table</h2>
<p>Back on the Design View, we now need to create a table which we&#8217;ll use to display the listings from the catalog. This is where that schema data connection will come-in handy as we&#8217;ll see a little later.</p>
<p>Our table will display 4 columns: title, actor name, category name and cost. Drag a table object onto the top-left corner of the page and give it 1 header row, 1 body row and 4 columns:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-4.Png"> </p>
<p>We want the table to take-up the entire width of the page but we also want the first column, title, to be wider than the other 3 since the title is usually longer than names or a dollar amount. Start by making the last 3 columns a little wider by dragging the column separator between the 2nd and 3rd and 3rd and 4th columns to the right, leaving some room to make the first column wider. Then drag the column separator between the 1st and 2nd column to the right until it won&#8217;t move anymore, which indicates that it&#8217;s the widest the first column can be made while keeping the table constrained to the page&#8217;s width.</p>
<p>Now double-click in each header cell and rename them to &#8220;Title&#8221;, &#8220;Actor&#8221;, &#8220;Category&#8221; and &#8220;Cost&#8221; from left to right.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-5.Png"> </p>
<p>(Here I&#8217;ve also set a linear-to-bottom background gradient color on the header row.)</p>
<p>Next, we need to set some fields into the table row where the movie data will go since they&#8217;re only text objects by default. The first 3 columns need to be text fields and the last one should be a numeric field since it&#8217;ll contain a dollar amount.</p>
<p>Using the Hierarchy palette, select the &#8220;Cell1&#8243;, &#8220;Cell2&#8243; and &#8220;Cell3&#8243; objects in the &#8220;Row1&#8243; table row and change their object type (using the Object palette) to &#8220;Text Field&#8221;. While they&#8217;re still selected, set their Value Type to &#8220;Read Only&#8221;.</p>
<p>Now select the last cell in &#8220;Row1&#8243;, &#8220;Cell4&#8243;, and change its object type to &#8220;Numeric Field&#8221;. While it&#8217;s still selected, set its Value Type to &#8220;Read Only&#8221;, its Data Format to &#8220;Float&#8221; and click on the &#8220;Patterns&#8230;&#8221; button on the Object palette&#8217;s Field tab. In there, set the Display pattern to &#8220;numeric.currency{}&#8221; and set the Data pattern to &#8220;numeric.decimal{}&#8221;:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-6.Png"> </p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-7.Png"> </p>
<p>This will let the field accept a decimal number as its data and will cause it to be displayed with a currency symbol (e.g. &#8220;25.50&#8243; is displayed as &#8220;$25.50&#8243;).</p>
<p>Finally, rename &#8220;Table1&#8243; to &#8220;Listing&#8221; and &#8220;Row1&#8243; to &#8220;MovieRow&#8221;. Inside &#8220;MovieRow&#8221;, rename &#8220;Cell1&#8243; to &#8220;Title&#8221;, &#8220;Cell2&#8243; to &#8220;Actor&#8221;, &#8220;Cell3&#8243; to &#8220;Category&#8221; and &#8220;Cell4&#8243; to &#8220;Cost&#8221;.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-8.Png"> </p>
<h2>Schema Data Bindings</h2>
<p>The next thing on the list is setting the data bindings into the schema data connection we created earlier. This will ensure that when data is merged into the form, after being retrieved from the Movie Service, that instances of the MovieRow table row are created accordingly and the Title, Actor, Category and Cost fields they contain populated with the right data for a particular movie.</p>
<p>Select the MovieRow table row object and set its binding by choosing &#8220;MovieCatalogDC &gt; movie&#8221; from the binding popup button next to the Default Binding property. This will set the binding to &#8220;$.movie[*]&#8220;:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-9.Png"> </p>
<p>(The button next to the field that contains &#8220;$.movie[*]&#8221; is the binding popup button.)</p>
<p>This binding, with the &#8220;[*]&#8221; syntax, indicates that the MovieRow object will bind to all occurrences of the &lt;movie&gt; data group nodes in the data that gets merged into the form.</p>
<p>Finally, make the MovieRow repeatable with no min, no max but <strong>1 initial instance</strong>:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-10.Png"> </p>
<p>The initial instance is essential in getting around a bug with the Form Guide Repeater Data Grid panel layout which we&#8217;ll be using in part 3 of this tutorial.</p>
<p>The last bindings we need to set are on the Title, Actor, Category and Cost fields that make-up the MovieRow. Set them as follows:</p>
<ul>
<li>Title: &#8220;$.title&#8221;
<li>Actor: &#8220;$.actorName&#8221;
<li>Category: &#8220;$.catName&#8221;
<li>Cost: &#8220;$.cost&#8221;</li>
</ul>
<p>You can set these bindings manually or you can use the binding popup button to select the appropriate node from the MovieCatalogDC data connection. If you use the binding popup button, you&#8217;ll likely get the Binding Properties dialog, in which case you should choose to <strong>not</strong> to update any related properties as follows:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-11.Png"> </p>
<p>Under certain circumstances, the schema may contain more information about a particular element which could be automatically applied to the field such as name, caption and default value. Since we&#8217;ve already setup the fields ourselves (and since our sample XML schema didn&#8217;t have much information to start with), we don&#8217;t need this functionality.</p>
<h2>Form Guide Only Objects</h2>
<p>The final step in the form design is to include 4 objects which we&#8217;ll use only in the form guide that we&#8217;ll create in part 3 of this tutorial. We&#8217;ll need a listbox to hold the actor names, one to hold the category names, we&#8217;ll need a numeric field to hold the movie count and we&#8217;ll need a button that the user will click to fetch the movies that match the actor and/or category they will have selected in the lists (if any).</p>
<p>This is simpler to setup than it sounds. All we need to do is drag a new subform into the page (below the Listing table) and place two listboxes, one numeric field and one button inside. Rename the subform to &#8220;GuideObjects&#8221;.</p>
<p>Rename one listbox to &#8220;ActorList&#8221; and the other to &#8220;CategoryList&#8221;. Rename the numeric field to &#8220;MatchCount&#8221; and the button to &#8220;GetMovies&#8221;.</p>
<p>Set the ActorList field&#8217;s caption to &#8220;Choose an Actor (optional):&#8221; and the CategoryList field&#8217;s caption to &#8220;Choose a Category (optional):&#8221;. Set both field&#8217;s Value Type to &#8220;Read Only&#8221; since we don&#8217;t want the user to be able to interact with the listboxes until actor and category data are loaded into them (in the Form Guide, which we&#8217;ll see later in part 3).</p>
<p>Set the MatchCount field&#8217;s caption to &#8220;Number of matches:&#8221; and set its Value Type to &#8220;Read Only&#8221; as well since we&#8217;ll just be reporting the total number of movies that matched the criteria (actor and/or category or neither) and we won&#8217;t want the user to edit the result.</p>
<p>The bindings on both listboxes and the numeric field will be &#8220;None&#8221; by default which is fine. There&#8217;s no node in the schema to bind them to and we don&#8217;t need to bind them anyway.</p>
<p>Set the GetMovies button&#8217;s caption to &#8220;Get Movies&#8221;.</p>
<p>Finally, to make sure all the guide-only objects are hidden in the form, set the Initialize script of the GuideObjects subform to hide itself if the context isn&#8217;t the Form Guide. You can determine what the context is by checking the value of the <strong>xfa.host.name</strong> property. If it&#8217;s &#8220;Flash&#8221;, then you know the script is executing within the context of the Form Guide, not Acrobat. This will be very important in part 2 when we write the ActionScript code necessary to fetch the data from the Movie Service:</p>
<pre><code>if (xfa.host.name != "Flash")
    this.presence = "hidden";</code></pre>
<p>This is what the form should look like now:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-12.Png"> </p>
<p>(Note that the exact placement of the objects within the GuideObjects subform doesn&#8217;t matter since they&#8217;ll be positioned correctly in the Form Guide and won&#8217;t be displayed on the form itself.)</p>
<h2>Getting Rid of the Page Subform</h2>
<p>To ensure that our Listing table is free to expand and roll-out onto additional pages if there are a lot of movies returned in the listing, we need to move the Listing table and the GuideObjects subform out of the page subform and into the root subform (&#8220;movieList&#8221; at the top of the Hierarchy tree). We could just make the unnamed page subform flowed but that would introduce an extra level of subform hierarchy that just isn&#8217;t needed.</p>
<p>This can be done simply by right-clicking on the unnamed page subform &#8220;(untitled Subform) (page 1)&#8221; object in the Hierarchy palette and choosing the &#8220;Unwrap Subform&#8221; command. The hierarchy should now look like this:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-13.Png"> </p>
<h2>Testing the Form</h2>
<p>Before we go on to part 2 we should make sure that what we&#8217;ve done so far works correctly. To test our form, we simply need to merge-in some movie data from the Movie Service to make sure that it gets displayed properly in the Listing table.</p>
<p>You can get the full movie catalog listing simply by hitting this URL:</p>
<p><a href="http://forms.stefcameron.com/services/movies/">http://forms.stefcameron.com/services/movies/</a></p>
<p>Save what you get into an XML file named &#8220;movieCatalog-sample.xml&#8221; and set it as the Preview Data File for the form using the Form Properties dialog.</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-14.Png"> </p>
<p>Now preview the form using the &#8220;Preview PDF&#8221; tab. You should get something that looks like this:</p>
<p><img src="http://forms.stefcameron.com/images/Max2008/Max2008Tutorial-Part1-15.Png"> </p>
<p>After you&#8217;ve determined that the table is functioning correctly (which means that the bindings are working as expected), you should <strong>remove the Preview Data File setting</strong> since it&#8217;ll interfere with the Form Guide&#8217;s function later on. (A Preview Data File <em>can</em> be used to initialize data in a form guide however, in this case, we don&#8217;t want all the movie data to be there already; we want to query the Movie Service for it in real-time based on any actor and/or category settings the user may have specified.)</p>
<h2>Solution to Part 1</h2>
<p>Try not to peek at this before you attempt to build the form on your own&#8230;</p>
<p><a href="http://forms.stefcameron.com/samples/max2008/Max2008-MovieCatalog-Part1.zip">Download Part 1 [zip]</a></p>
<p><strong>Minimum Requirements:</strong> The form should work back to Designer 8.0 however it was designed with Designer 8.2.1 SP1.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2008/11/17/max-2008-tutorial-part1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Book now available: Creating Dynamic Forms with Adobe LiveCycle Designer</title>
		<link>http://forms.stefcameron.com/2007/08/30/book-now-available-creating-dynamic-forms-with-adobe-livecycle-designer/</link>
		<comments>http://forms.stefcameron.com/2007/08/30/book-now-available-creating-dynamic-forms-with-adobe-livecycle-designer/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 12:47:50 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Instance Manager]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tables]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2007/08/30/book-now-available-creating-dynamic-forms-with-adobe-livecycle-designer/</guid>
		<description><![CDATA[That&#8217;s right: The day has finally come! Designer officially has its very first book on the market, thanks to J.P. Terry at SmartDoc Technologies. The book is the result of J.P.&#8217;s own expertise and&#160;a collaborative effort&#160;with the Designer Team in Ottawa. It&#160;tackles form design and techniques in&#160;building dynamic XML-based PDF forms with Designer. As Alan [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s right: The day has finally come! Designer officially has its very first book on the market, thanks to <a href="http://www.adobe.com/devnet/livecycle/articles/graph_effective_form_design_pt3.html">J.P. Terry</a> at <a href="http://www.smartdoctech.com/">SmartDoc Technologies</a>.</p>
<p><img src="http://forms.stefcameron.com/images/designer-book-cover.jpg"> </p>
<p>The book is the result of J.P.&#8217;s own expertise and&nbsp;a collaborative effort&nbsp;with the Designer Team in Ottawa. It&nbsp;tackles form design and techniques in&nbsp;building dynamic XML-based PDF forms with Designer.</p>
<p>As <a href="http://www.amazon.com/Alan-Siegel-Branding-Clear-Communications/dp/0979076641/ref=pd_bbs_sr_1/002-0743263-5124812?ie=UTF8&amp;s=books&amp;qid=1188313311&amp;sr=8-1">Alan Siegel</a> (Founder &amp; Chairman of <a href="http://www.siegelgale.com/">Siegel+Gale</a>, branding pioneer and champion of simplifying corporate communications)&nbsp;put it,</p>
<p>&#8220;J.P. Terry is a rare individual who understands both the design and technical issues involved with effective communications. This book will teach you about LiveCycle Designer but more importantly it will teach you about effective form design.&#8221;<br />
<h2>How to get the book</h2>
<p>The book is now available for immediate ordering at the following sites</p>
<ul>
<li><a href="http://www.peachpit.com/store/product.aspx?isbn=0321509870">PeachPit Press</a>
<li><a href="http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?z=y&amp;EAN=9780321509871&amp;itm=4">Barnes &amp; Noble</a></li>
</ul>
<p>as well as at various local bookstores.</p>
<p>For some reason, it&#8217;s still on &#8220;pre-order&#8221; status at <a href="http://www.amazon.com/Creating-Dynamic-Forms-LiveCycle-Designer/dp/0321509870/ref=sr_1_1/102-3863700-7455308?ie=UTF8&amp;s=books&amp;qid=1178140262&amp;sr=1-1">Amazon.com</a>&nbsp;but should be &#8220;officially&#8221; available shortly.</p>
<p>The Designer book&nbsp;will also be&nbsp;available for purchase at <a href="http://adobemax2007.com">MAX 2007</a>&nbsp;and I will be <strong>giving away a copy or two at my hands-on sessions</strong> on <a href="http://adobemax2007.com/na/sessions/">Designing PDF Forms and Flex-based Form Guides</a> so be sure to attend if you&#8217;re at <a href="http://www.adobemax2007.com/na/">MAX 2007 North America</a>!</p>
<h2>Sample Files Posted</h2>
<p>For those of you who already have the book, you can now download the <a href="http://www.smartdoctech.com/books.aspx">sample files from SmartDocTech.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2007/08/30/book-now-available-creating-dynamic-forms-with-adobe-livecycle-designer/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

