<?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; Form Guides</title>
	<atom:link href="http://forms.stefcameron.com/category/form-guides/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>FormFeed Debugging Tips</title>
		<link>http://forms.stefcameron.com/2009/05/27/formfeed-debugging-tips/</link>
		<comments>http://forms.stefcameron.com/2009/05/27/formfeed-debugging-tips/#comments</comments>
		<pubDate>Wed, 27 May 2009 20:28:34 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Form Guides]]></category>
		<category><![CDATA[Script Editor]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/05/27/formfeed-debugging-tips/</guid>
		<description><![CDATA[My friend John Brinkman has posted a really good list of handy form development and debugging tips. Check it out! These tips could save you a lot of time and effort. I use them all the time when I work on forms with Designer, Acrobat and LiveCycle Forms. One other nice thing about console.println() for [...]]]></description>
			<content:encoded><![CDATA[<p>My friend John Brinkman has posted a <a href="http://blogs.adobe.com/formfeed/2009/05/collected_form_development_and.html">really good list</a> of handy form development and debugging tips. Check it out! These tips could save you <em>a lot</em> of time and effort. I use them all the time when I work on forms with Designer, Acrobat and LiveCycle Forms.</p>
<p>One other nice thing about <a href="http://forms.stefcameron.com/2006/05/05/debugging-scripts/">console.println()</a> for outputting debug information to the JavaScript Console in Acrobat is that these strings are also output to the Flash Log when you run <a href="http://forms.stefcameron.com/category/form-guides/">form guides</a> generated with LiveCycle ES Update 1 (8.2.1) using the Flash Debug Player. (The <a href="http://forms.stefcameron.com/2008/11/19/max-2008-tutorial-part3/">3rd part</a> of my MAX 2008 Tutorial series has details on how to set this up under the &#8220;Flash Log and Debug Players&#8221; section.)</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/05/27/formfeed-debugging-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto-Identify Mandatory Fields</title>
		<link>http://forms.stefcameron.com/2009/03/16/auto-identify-mandatory-fields/</link>
		<comments>http://forms.stefcameron.com/2009/03/16/auto-identify-mandatory-fields/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 12:00:41 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Form Guides]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/03/16/auto-identify-mandatory-fields/</guid>
		<description><![CDATA[I am certain at some point in time you have had to fill-out some type of form on a website and the required fields were identified by an asterisk (*). This is a common way to communicate to a user which fields are mandatory and which ones aren&#8217;t. This is a design pattern that the [...]]]></description>
			<content:encoded><![CDATA[<p>I am certain at some point in time you have had to fill-out some type of form on a website and the required fields were identified by an asterisk (<font color="#ff0000"><strong>*</strong></font>). This is a common way to communicate to a user which fields are mandatory and which ones aren&#8217;t.</p>
<p>This is a design pattern that the <a href="http://blogs.adobe.com/lcformguides/">Form Guide Team</a> adopted when they conceived the default <a href="http://forms.stefcameron.com/category/form-guides/">Form Guide</a> user experience. Since the appearance of a field in a form guide doesn&#8217;t have to be the same as that of the field in the form (PDF), they were able to automatically add an asterisk next to mandatory fields without affecting their PDF counterparts.</p>
<p><span id="more-336"></span>
<p>For example, in the following images, the Name and Address fields are mandatory (&#8220;Object palette &gt; Value tab &gt; Type property&#8221; is set to &#8220;User Entered &#8211; Required&#8221;) while the rest are optional. Notice how the captions of the Name and Address fields in the Form Guide have asterisks while the ones in the PDF don&#8217;t (and I didn&#8217;t have to do anything other than include those fields in a panel in a Form Guide in order to get this functionality):</p>
<p><img title="Asterisks on mandatory fields in Form Guide" alt="Asterisks on mandatory fields in Form Guide" src="http://forms.stefcameron.com/images/IdentifyMandatoryFields/IdentifyMandatoryFields-1.jpg"><br />&mdash; Form Guide</p>
<p><img title="No asterisks by default on mandatory fields in the PDF" alt="No asterisks by default on mandatory fields in the PDF" src="http://forms.stefcameron.com/images/IdentifyMandatoryFields/IdentifyMandatoryFields-2.jpg"><br />&mdash; PDF</p>
<p>Unfortunately, while XFA gives us the ability to mark a field as mandatory, Acrobat/Reader doesn&#8217;t automatically set them apart like the Form Guide does. Perhaps that&#8217;s a good thing because it gives you full control over how to identify fields as being mandatory.</p>
<p>Mandatory fields could be highlighted in different ways: An asterisk, a different <a href="http://forms.stefcameron.com/2008/03/14/field-background-color-fill/">background color</a> or various other types of styles. If you use an asterisk, however, the tendency is to put it in the caption but doing this manually can be tedious if there are a lot of fields. What if some fields only become mandatory after certain conditions are met as the user is filling the form? If you don&#8217;t put the asterisk in the field&#8217;s caption (so that you can easily show/hide it when necessary using script), then you risk getting into various layout issues trying to get the asterisk to show-up at the right position next to each field. It also means lots more form objects which could really bloat your form.</p>
<p>That&#8217;s why I decided to implement a script that automatically adds the asterisk to a field&#8217;s caption. That way, you don&#8217;t have to worry about the asterisk &#8212; just mark the field as mandatory, run the script on initialization and it will search the entire form, placing a red asterisk in the captions of mandatory fields regardless of nesting levels. Furthermore, if you decide to use a text object as a caption next to a caption-less field or radio button list, the script will mark it with an asterisk as well (provided the text object&#8217;s name is the same as the field/radio button list&#8217;s but with a &#8220;_Caption&#8221; postfix).</p>
<p>Applying my script to the sample above would yield the following results in the PDF without affecting field appearances in the Form Guide:</p>
<p><img title="Asterisks added to mandatory fields in PDF" alt="Asterisks added to mandatory fields in PDF" src="http://forms.stefcameron.com/images/IdentifyMandatoryFields/IdentifyMandatoryFields-3.jpg"><br />&mdash; PDF</p>
<h2>mandatoryLib</h2>
<p>The following sample form references the auto-asterisk script in the <em>mandatoryLib</em> script object <a href="http://forms.stefcameron.com/category/form-fragments/">fragment</a>. I suggest you download the fragment (see link below) and reference it in all the forms in which you want to use the script. Feel free to enhance it as well if it doesn&#8217;t work quite right for your particular needs: The script is heavily commented so it should be easy to follow and extend.</p>
<p>There are two functions you can call:</p>
<ul>
<li><strong>IdentifyMandatoryFields(formObj)</strong>: Given a form object (field or container such as radio button list or subform), find all mandatory fields inside (all nesting levels) and add an asterisk to their captions (actual captions or text object captions).
<li><strong>ToggleMandatoryField(formObject, isMandatory)</strong>: Given a field or radio button list, toggle its mandatory state by adding (isMandatory == true) or removing (isMandatory == false) the asterisk.</li>
</ul>
<p>Furthermore, since the scripts handles both plain and rich text captions, you don&#8217;t have to worry about making sure all captions use rich text formatting.</p>
<p><strong>Note about rich text:</strong> If you look at the script, you&#8217;ll notice that the rich text value of a field&#8217;s caption or text object&#8217;s content is retrieved from the Template DOM rather than the Form DOM. The Template DOM is where the design-time form object definitions are stored (it&#8217;s what you define when you edit the form in Designer) and cannot be modified at runtime (i.e. Acrobat/Reader) while the Form DOM, generated at runtime, is very sparse and contains only what is needed to render the form object in its current state. That means as long as there are no modifications to the rich text value, it will not appear in the Form DOM and must be retrieved from the Template DOM instead. One draw-back of this issue is that if you make any modifications to the caption/text object and then run the script, those modifications will be lost because the script will use the un-modified rich text from the Template DOM rather than your modifications stored in the Form DOM.</p>
<p><a href="http://forms.stefcameron.com/samples/IdentifyMandatoryFields.pdf">Download Sample [pdf]</a> (if you plan on editing this Designer, you&#8217;ll also need the fragment below in the same folder)</p>
<p><a href="http://forms.stefcameron.com/samples/mandatoryLib.xdp">Download mandatoryLib Fragment [xdp]</a> (to download, right-click on the link and choose &#8220;Save Link As&#8230;&#8221;)</p>
<p><strong>Special Thank You</strong> to my friends at <a href="http://avokahhh.wordpress.com/">Avoka</a> for pointing-out that my original solution didn&#8217;t handle mandatory fields in repeating subform instances.</p>
<p><strong>Sample Minimum Requirements:</strong> Since the script object uses <a href="http://forms.stefcameron.com/2009/02/11/careful-with-form-compatibility-settings/">dynamic object variables</a> for optimization, I had to set it to use XFA 2.8 which means you&#8217;ll need Acrobat/Reader 9.0 to run it.</p>
<p><strong>mandatoryLib Minimum Requirements:</strong> You could probably get away with running this script in an XFA 2.5 form (Acrobat/Reader 8.0), maybe even less, but the optimizations with the $formObjMap object may not function properly due to an aggressive JavaScript Garbage Collector in earlier versions (in other words, the script may run slower but it should still run).</p>
<p class="postUpdate"><strong>Aug 28, 2009</strong> &mdash; Separated mandatoryLib script object out into a script object fragment.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/03/16/auto-identify-mandatory-fields/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Form Guide + PDF in AIR</title>
		<link>http://forms.stefcameron.com/2009/02/26/form-guide-pdf-in-air/</link>
		<comments>http://forms.stefcameron.com/2009/02/26/form-guide-pdf-in-air/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 22:06:17 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Form Guides]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2009/02/26/form-guide-pdf-in-air/</guid>
		<description><![CDATA[Check this out: My colleague Trevor Ward, developer on the Form Guide Team, has just posted a very cool sample of an AIR app running a Form Guide complete with data and an embedded PDF on the LiveCycle Form Guide blog. Please keep in mind that it&#8217;s just a proof-of-concept but it should give you [...]]]></description>
			<content:encoded><![CDATA[<p>Check this out: My colleague Trevor Ward, developer on the Form Guide Team, has <a href="http://blogs.adobe.com/lcformguides/2009/02/form_guide_in_an_air_app_with.html">just posted</a> a very cool sample of an AIR app running a Form Guide complete with data and an embedded PDF on the <a href="http://blogs.adobe.com/lcformguides/">LiveCycle Form Guide blog</a>. Please keep in mind that it&#8217;s just a proof-of-concept but it should give you enough to go on to build your own solution if you&#8217;ve been wondering if/how this could be done.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2009/02/26/form-guide-pdf-in-air/feed/</wfw:commentRss>
		<slash:comments>4</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; Preview</title>
		<link>http://forms.stefcameron.com/2008/11/14/max-2008-tutorial-preview/</link>
		<comments>http://forms.stefcameron.com/2008/11/14/max-2008-tutorial-preview/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 17:44:56 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Form Guides]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=275</guid>
		<description><![CDATA[As I mentioned earlier, I&#8217;m working on a tutorial in the spirit of the Adobe MAX 2008 conference which I&#8217;ll make available next week. There will be 3 posts, one for each day of the conference. This tutorial will show you how to (1) design a form with a table that has a repeating row, [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned <a href="http://forms.stefcameron.com/2008/11/11/if-i-were-going-to-max-2008/">earlier</a>, I&#8217;m working on a tutorial in the spirit of the <a href="http://max.adobe.com/">Adobe MAX 2008</a> conference which I&#8217;ll make available next week. There will be 3 posts, one for each day of the conference.</p>
<p>This tutorial will show you how to (1) design a form with a table that has a repeating row, (2) add some Flex code to it that will enable 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 for retrieving data from my <a href="http://forms.stefcameron.com/services/movies/?help=1">Movie Service</a> and (3) design a form guide that will capture the data from the service and transfer it into the PDF which could then be used to print or archive the movie listings.</p>
<p>In an effort to wet your appetite, I thought I would get the ball rolling by showing a little <a target="_blank" href="http://my.adobe.acrobat.com/max-2008-tutorial-preview/">preview of the final solution</a>.</p>
<p>Be sure to come back every day, Monday to Wednesday next week (November 17-19, 2008), to get the full tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2008/11/14/max-2008-tutorial-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto-splitting text between two text fields</title>
		<link>http://forms.stefcameron.com/2008/07/10/auto-splitting-text-between-two-text-fields/</link>
		<comments>http://forms.stefcameron.com/2008/07/10/auto-splitting-text-between-two-text-fields/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 15:09:48 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Acrobat]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Form Guides]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/2008/07/10/auto-splitting-text-between-two-text-fields/</guid>
		<description><![CDATA[The scenario You have a compliant form that has sections for users to fill-in information. Because the form is compliant (i.e. its layout has received the &#8220;stamp of approval&#8221; and cannot change without another lengthy approval process), the sections cannot grow (they cannot expand-to-fit all of the text users may fill-in). To provide more space [...]]]></description>
			<content:encoded><![CDATA[<h2>The scenario</h2>
<p>You have a compliant form that has sections for users to fill-in information. Because the form is compliant (i.e. its layout has received the &#8220;stamp of approval&#8221; and cannot change without another lengthy approval process), the sections cannot grow (they cannot <a href="http://forms.stefcameron.com/2006/10/31/expanding-to-fit-the-entire-value/">expand-to-fit</a> all of the text users may fill-in). To provide more space for users to add more text, you&#8217;ve provided an expandable &#8220;overflow&#8221; section at the end of form since expanding that section will not affect the portion of the form which has been approved.</p>
<h2>The problem</h2>
<p>You need to capture the text entered into the form using an interactive <a href="http://blogs.adobe.com/lcformguides/">Form Guide</a> which is not limited to the restrictions of the form&#8217;s approved layout. As such, the Form Guide will capture the text in a single field and you need that text to be entered into the PDF version of the form. If you put all the text into the appropriate section on the form, it won&#8217;t fit and the text will be cut-off (e.g. it will not print entirely and you will miss some of the important information).</p>
<p>You need some way to automatically split that text between the small section in the form and the overflow section at the end of the form. In other words, you need to ensure that only the text that can fit within the small form section is placed there and the rest is placed in the overflow section at the end.</p>
<p>In <a href="http://forms.stefcameron.com/2008/07/03/acrobat-pro-9-with-designer-82-now-available/">Designer 8.2</a>, the content of fields can now be split between pages however in this case, you can&#8217;t use this feature because the small form section can&#8217;t be expanded (it&#8217;s fixed in size).</p>
<h2>The solution</h2>
<p>This is the problem Stephanie, Glenn and I were faced with on a recent customer visit. <a href="http://blogs.adobe.com/lcdesigner/2008/07/an_example_of_splitting_text_a.html">Stephanie took the time</a> to put this into a <a href="http://blogs.adobe.com/lcdesigner/ScriptSplit.pdf">sample form</a> which provides the script we wrote to handle this task. It&#8217;s basically a mini text parser written in JavaScript that splits text between two fields with a fixed-width font (e.g. Courier New, Lucida Console, etc.).</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2008/07/10/auto-splitting-text-between-two-text-fields/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Video Tutorial on Customizing Form Guides</title>
		<link>http://forms.stefcameron.com/2008/04/14/video-tutorial-on-customizing-form-guides/</link>
		<comments>http://forms.stefcameron.com/2008/04/14/video-tutorial-on-customizing-form-guides/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 13:53:03 +0000</pubDate>
		<dc:creator>Stefan Cameron</dc:creator>
				<category><![CDATA[Form Guides]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://forms.stefcameron.com/?p=144</guid>
		<description><![CDATA[A colleague of mine on the Form Guide Team, Gilles Maurice, has assembled an extensive video-based tutorial on customizing Form Guides (a new Flash/Flex-based form technology available as of LiveCycle Designer 8.1) using Flex Builder, sample code included. This tutorial goes beyond the customizations you can do with the Guide Builder tool and uses Flex [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague of mine on the Form Guide Team, Gilles Maurice, has assembled an extensive <a href="http://www.adobe.com/devnet/livecycle/articles/customizing_formguides.html">video-based tutorial on customizing Form Guides</a> (a new Flash/Flex-based form technology available as of LiveCycle Designer 8.1) using Flex Builder, sample code included.</p>
<p>This tutorial goes beyond the customizations you can do with the Guide Builder tool and uses Flex Builder to create customized guide and panel layouts as well as customized components for displaying data and more. If you&#8217;re in to form guides or you&#8217;re curious about what you can do with this technology, this should be well worth your time!</p>
]]></content:encoded>
			<wfw:commentRss>http://forms.stefcameron.com/2008/04/14/video-tutorial-on-customizing-form-guides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

