tag:blogger.com,1999:blog-79706790500258999672024-03-13T03:35:36.671-07:00Adobe LiveCycle Designer Cookbooks by BR001This is a copy of Adobe LiveCycle Designer Cookbooks I had on the Adobe Developer Connection before they stopped being available.
There are also some code samples used in answering questions on the LiveCycle Designer forum.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.comBlogger45125tag:blogger.com,1999:blog-7970679050025899967.post-73426943133558187842018-04-13T14:45:00.003-07:002021-01-01T13:44:07.905-08:00An alternative Date Picker for LiveCycle Designer forms<h2>
Problem</h2>
The standard date/time field that is supplied with Designer is fairly simple with
no options to control its behaviour. There is no way to force the use of the date
picker, they can always enter a date with the keyboard. There is no way to specify
a default date, so if you are after the date of birth you have to click the previous
month button so often it becomes unusable. There is no way to programmatically open
the date picker. And, there is no way to set min and max dates.<br />
<br />
<h2>
Solution</h2>
This alternative has some serious limitations as well as it really just a normal
subform I position against a standard text field. To do this the text field has
to be within a subform that uses positioned layout so I can calculate the x andy
coordinates.<br />
<br />
<h2>
Detailed explanation</h2>
I have added some options to control the color and format of the date picker but
because this is just a standard subform you can modify it to suit your needs. For
example I have also added previous and next year buttons.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-XvfBMaL4_Dg/UZNjWmgMxaI/AAAAAAAAAC0/jTg4CI3YRhc/s1600/Calendar.png" style="margin-left: 1em; margin-right: 1em;">
<img border="0" height="108" src="https://1.bp.blogspot.com/-XvfBMaL4_Dg/UZNjWmgMxaI/AAAAAAAAAC0/jTg4CI3YRhc/w400-h108/Calendar.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
The options can be set in the initialise event of the text field, for example, to
set the date format, tool tip format and the min and max values (XFAUtil is my helper
script object to add values to a fields <desc> element);</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; line-height: 1; text-align: left;">
<span style="font-family: " courier new" , "courier" , monospace; font-size: xx-small;">
XFAUtil.setProperty(<span style="color: blue;">this</span>, DatePicker.Controller.Properties.ToolTipFormat.Name,
<span style="color: orange;">"date.long{}"</span>, XFAUtil.ContentType.Text);<br />
XFAUtil.setProperty(<span style="color: blue;">this</span>, DatePicker.Controller.Properties.DateFormat.Name,
<span style="color: orange;">"date.long{}"</span>, XFAUtil.ContentType.Text);<br />
XFAUtil.setProperty(<span style="background-color: white; color: blue;">this</span>,
DatePicker.Controller.Properties.MinValue.Name, <span style="color: blue;">new</span>
Date(new Date().getFullYear(),0,1), XFAUtil.ContentType.Text);<br />
XFAUtil.setProperty(<span style="color: blue;">this</span>, DatePicker.Controller.Properties.MaxValue.Name,
<span style="color: blue;">new</span> Date(new Date().getFullYear(),11,31), XFAUtil.ContentType.Text);</span></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Then when the text field receives focus, (in the enter event) show the date picker.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<span style="font-family: " courier new" , "courier" , monospace; font-size: xx-small;">
DatePicker.Controller.show(<span style="color: blue;">this</span>);</span><br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
And to stop a date being enter via the keyboard, in the change event;</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: " courier new" , "courier" , monospace;"><span style="font-size: xx-small;">
xfa.event.change = <code class="jscript string"><span style="color: orange;">""</span></code><code class="jscript plain">;</code></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
The code in the actual date picker is reasonably well commented (at least for me)
so I wont discribe it here.</div>
<h3>
<br />
JavaScript Date Handling</h3>
There are a number of functions within FormCalc that make converting dates very
easy. For example to convert the string "4 Janvier, 2011" to a date we can use the
FormCalc function parse("date(fr){EEEE, D MMMM YYYY}", "4 Janvier, 2011").<br />
<br />
To do this in JavaScript I use a hidden Date/Time field and the formattedValue,
which I would normally use to retrieve a value but we can also assign a value to
it;
<br />
<br />
Download sample <a href="https://drive.google.com/uc?export=download&id=1JrVYMOmoY9b-HkrEGZ_KFDlJs4VAuGqU">
Calendar.pdf</a>, or all the .XDP files, <a href="https://drive.google.com/uc?export=download&id=106vgFEvNvF7ARupEVNlxv4IfPbqRP_O-">Calendar.zip</a>.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com5tag:blogger.com,1999:blog-7970679050025899967.post-60221440917493878852016-07-05T04:12:00.002-07:002020-12-30T21:53:34.417-08:00Escaping the “&” character in a submission email
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Myriad Pro",sans-serif; font-size: 10pt; mso-bidi-font-family: "Myriad Pro";">Within
a mailto URL, as used by the EmailSubmitButton, the character "&"
has a special meaning as a separator between the headers (to, cc, subject,
etc).<span style="mso-spacerun: yes;"> </span>In an HTML page a "&"
character within the header value can be escaped as %26, but in the mysterious
world of LiveCycle Designer forms the “%” needs to be escaped as well, giving
us %2526.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Myriad Pro",sans-serif; font-size: 5pt; mso-bidi-font-family: "Myriad Pro";"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: "Myriad Pro",sans-serif; font-size: 10pt; mso-bidi-font-family: "Myriad Pro";">For
example;<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none;">
<span style="font-family: "Courier Std"; font-size: 10pt; mso-bidi-font-family: "Courier Std";">mailto:?subject=Q%2526A<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Myriad Pro",sans-serif; font-size: 10pt; mso-bidi-font-family: "Myriad Pro";">Generates
an email with the subject of “Q&A”.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Myriad Pro",sans-serif; font-size: 10pt; mso-bidi-font-family: "Myriad Pro";">This
sample form uses the following code in the "Submit by Email" button
to generate the mailto URL and uses two calls the </span><span style="font-family: "Courier New"; font-size: 8pt;">encodeURIComponent</span><span style="font-family: "Myriad Pro",sans-serif; font-size: 10pt; mso-bidi-font-family: "Myriad Pro";"> generate the correct escaping for the "&"
character .<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">var</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> encodedAmpersand </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">=</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">
encodeURIComponent(encodeURIComponent(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"&"</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">var</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> headers </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">=</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> [];</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 2;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">if</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> (</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">!</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">To.isNull) headers.push(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"to="</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">+</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> To.rawValue);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">if</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> (</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">!</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">CC.isNull) headers.push(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"cc="</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">+</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> CC.rawValue);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">if</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> (</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">!</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">BCC.isNull) headers.push(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"bcc="</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">+</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> BCC.rawValue);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">if</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> (</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">!</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">Subject.isNull) headers.push(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"subject="</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">+</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> Subject.rawValue.replace(</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">/&/</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">g</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">,</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">
encodedAmpersand));<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">if</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> (</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">!</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">Body.isNull) headers.push(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"body="</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">+</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">
Body.rawValue.replace(</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">/&/</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">g</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">,</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> encodedAmpersand));<o:p></o:p></span></div>
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 3;"> </span></span><br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 8pt;">var</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> mailtoTarget </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">=</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> </span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"mailto:?"</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> </span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">+</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> headers.join(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"&"</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"></span></span> </div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none; tab-stops: 24.0pt 48.0pt 72.0pt 96.0pt 120.0pt 144.0pt 168.0pt 192.0pt 216.0pt 240.0pt 264.0pt 288.0pt 312.0pt 336.0pt 360.0pt 384.0pt 408.0pt 432.0pt 456.0pt 480.0pt 504.0pt 528.0pt 552.0pt 576.0pt 600.0pt 624.0pt 648.0pt 672.0pt 696.0pt 720.0pt 744.0pt;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;">EmailSubmitButton.event__click.submit.target
</span><span style="color: blue; font-family: "Courier New"; font-size: 8pt;">=</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;"> mailtoTarget;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;">EmailSubmitButton.execEvent(</span><span style="color: #ff9900; font-family: "Courier New"; font-size: 8pt;">"click"</span><span style="color: black; font-family: "Courier New"; font-size: 8pt;">);</span><span style="font-family: "Myriad Pro",sans-serif; font-size: 10pt; mso-bidi-font-family: "Myriad Pro";"> <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Myriad Pro",sans-serif; font-size: 10pt; mso-bidi-font-family: "Myriad Pro";">Note:
This only applies to submission emails using an Email Submit Button.<span style="mso-spacerun: yes;"> </span>If you are using app,mailMsg() or a mailto
URL in a rich text hyperlink then you just use %26.</span><o:p></o:p></div>
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 8pt;">
<span style="font-family: Calibri;">The sample form, <a href="https://drive.google.com/uc?export=download&id=1FIPZayeK44Go6_Ppy7VVXyPM7iVzAANQ">mailto&.pdf</a>, just tests the above code<o:p></o:p></span></div>
<span style="font-size: medium;"><span style="color: #2e74b5;"><span style="font-family: Calibri Light;">Event propagation<o:p></o:p></span></span></span><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 8pt;">
<span style="font-family: Calibri;">The sample form shows the XML of the Email Submit Button as
you type into the form fields for To, CC, BCC, Subject and Body.<span style="mso-spacerun: yes;"> </span>This was done using event propagation, so the
sample will only work in Reader 9.1 or later, though the technic of escaping
the “&” will work in earlier versions.<span style="mso-spacerun: yes;">
</span>The trick here was to have the change event on a subform.<span style="mso-spacerun: yes;"> </span>A subform does not support the change event
so Designer does not allow you to enter the code.<span style="mso-spacerun: yes;"> </span>However, it does still seem to work you just
need to enter the code in the XML Source view.<o:p></o:p></span></div>
BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-25942994031899021762015-04-30T00:00:00.001-07:002020-12-30T15:18:35.770-08:00Using the Jasmine testing framework in an Adobe Designer LiveCycle Form<a href="http://jasmine.github.io/2.0/introduction.html">Jasmine</a> is a popular testing framework for JavaScript applications. There's lots of tutorials on using Jasmine so I wont go into a lot of detail but as an example if we had a form that has a item price field, a quantity field and a total field with Jasmine we can write a test something like;<br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> describe<span style="color: orange;">("Total Calculation: </span><span style="color: blue;"><span style="color: orange;">"</span>, function</span>()<br /> {<br /> beforeEach(<span style="color: blue;">function</span> ()<br /> {<br /> TotalPriceCalculation.ItemPrice.rawValue <span style="color: blue;">=</span> <span style="color: orange;">1.75</span>;<br /> TotalPriceCalculation.Quantity <span style="color: blue;">=</span> <span style="color: orange;">5000</span>;<br /> TotalPriceCalculation.Total.execCalculate();<br /> });<br /><br /> it(<span style="color: orange;">"Equals ItemPrice * Quantity"</span><span style="color: blue;">, function</span>()<br /> {<br /> expect(TotalPriceCalculation.Total.rawValue).toEqual(<span style="color: orange;">8750</span>);<br /> });<br /> it(<span style="color: orange;">"Formatted in Australian Dollars "</span>, <span style="color: blue;">function</span>()<br /> {<br /> expect(TotalPriceCalculation.Total.formattedValue).toEqual(<span style="color: orange;">"$8,750.00"</span>);<br /> });<br /> });</span></div>
<br />
This is JavaScript code, <span style="font-family: Courier New; font-size: x-small;">describe</span>, is a Jasmine function that takes a description and function as arguments. <span style="font-family: Courier New; font-size: x-small;">beforeEach</span> is another function that is executed before every <span style="font-family: Courier New; font-size: x-small;">it</span> function which performs the actual test. The above test will hopefully give us a result like;<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-HNE1nWpjBSk/VTzc4Q8BktI/AAAAAAAAARo/PWFZ0povW9s/s1600/Jasmine.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-HNE1nWpjBSk/VTzc4Q8BktI/AAAAAAAAARo/PWFZ0povW9s/s1600/Jasmine.png" height="75" width="320" /></a></div>
<br />
The <span style="font-family: Courier New; font-size: x-small;">toEqual</span> function after the <span style="font-family: Courier New; font-size: x-small;">expect</span> is one of the standard Jasmine matches, the complete list is;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">toBe( null | true | false ) <br />toEqual( value ) <br />toMatch( regex | string ) <br />toBeDefined() <br />toBeUndefined() <br />toBeNull() <br />toBeTruthy() <br />toBeFalsy() <br />toContain( string ) <br />toBeLessThan( number ) <br />toBeGreaterThan( number ) <br />toBeNaN() <br />toBeCloseTo( number, precision )</span> <br />
<br />
And the Jasmine framework allows us to add our own matches, so for the XFA environment I have added;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">toBeVisible()<br />toBeInvisible()<br />toBeHidden()<br />toBeMandatory()<br />toBeProtected()<br />toBeOpen()<br />toBeValid()<br />toBeXFANull()<br />toHaveItemCount( number )<br />toHaveError( string )<br />toHaveFontColor ( "r,g,b" )</span><br />
<br />
These are just helper functions <span style="font-family: Courier New;">target.</span><span style="font-family: Courier New;">toBeVisible()</span> is the same as <span style="font-family: "Courier New", Courier, monospace;">target.presence.toEqual(<span style="color: orange;">"visible"</span>)</span>.<br />
<br />
Other helper functions added for the XFA environment are<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: #38761d;"> /**<br /> * Raises the change event for a specified field<br /> * @param {XFA object} field The target field of the change event<br /> * @param {string} newText The value of the field after the change is applied<br /> * @param {string} [change=newText] The value typed or pasted into the field that raises the change event<br /> * @param {boolean} [keyDown=false] The user is using an arrow key (listbox and dropdown only)<br /> * @param {boolean} [modifier=false] The user is holding the Ctrl key down<br /> * @param {boolean} [shift=false] The user is holding the shift key down<br /> */</span><br /><span style="color: blue;">function <span style="color: black;">execChangeEvent</span></span>(field, newText, change, keyDown, modifier, shift) {</span><br />
<span style="font-family: Courier New; font-size: xx-small;"></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: #38761d;"> /**<br /> * Raises the exit event for a specified field<br /> * @param {XFA object} field The target field of the exit event<br /> * @param {various} rawValue The value of the field before the exit event called, undefined doesn't update the field<br /> * @param {string} [commitKey=3] How the current value of the field was set: 0 - not set, escape key pressed, 1 - mouse click, 2 - enter key, 3 - tabbing<br /> * @param {boolean} [modifier=false] The user is holding the Ctrl key down<br /> * @param {boolean} [shift=false] The user is holding the shift key down<br /> */</span><br /><span style="color: blue;">function</span> execExitEvent(field, rawValue, commitKey, modifier, shift) {</span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: #38761d;"> /**<br /> * Reset fields to their default values<br /> */</span><br /><span style="color: blue;">function</span> resetData(/*arguments*/) {</span><br />
<br />
In this sample Jasmine.xdp is a script object which is the standalone Jasmine code download with a fairly small modification to cater for the differences in the Adobe JavaScript environment. The changes are commented at the start of the code but relate to the <span style="font-family: "Courier New", Courier, monospace;">app.setTimeOut()</span> function taking a string instead of a JavaScript statement.<br />
<br />
Hopefully this sample will give you enough to get you going <a href="https://drive.google.com/uc?export=download&id=190irbSwa0eyaOrB8gXgPCUp2E8iTpwdK">JasmineSample.pdf</a>. All the tests in this sample pass but when you get some that fail an exception will be thrown, you may want to set "When exception is thrown" to ignore in Acrobat JavaScript options.<br />
<br />
The XFA bootstrap is in <span style="font-family: "Courier New", Courier, monospace;">JasmineXFA.xdp</span> and the Jasmine test are in <span style="font-family: "Courier New", Courier, monospace;">JasmineSpec.xdp</span>, all zipped in <a href="https://drive.google.com/uc?export=download&id=1OkMxwx3FYShAIcQ5VV79SzunWGZSDSQu">JasmineXDP.zip</a> with the XDP of the sample.<br />
<br />
The <span style="font-family: "Courier New", Courier, monospace;">JasmineSpec.xdp</span> is a form fragment, the tests are run as part of a click event of the "Run Jasmine Specs" button, the results are displayed in a text object in the same fragment. The click event must start with the statement;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">var jasmine = JasmineXFA.Bootstrap({environment:this})</span><br />
<br />
this, adds the Jasmine functions and the XFA helpers and ends with the statement;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">jasmine.getEnv().execute(); </span><br />
<br />
Which starts the actual tests.<br />
<br />
The sample by default generates a pass/fail log to the console log as well. If you find generating output to the console log is getting in the way of your own debug statements you can turn the Jasmine output off by passing the <span style="font-family: Courier New; font-size: x-small;">includeConsoleReporter:false</span> option.<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">var jasmine = JasmineXFA.Bootstrap({environment:this, includeConsoleReporter:false})</span><br />
<br />
I tend to develop the tests as an embedded script object which allows me to use the control-click method of referencing fields, then when ready to be released change the script to a fragment and comment it out. The XDP file being an XML file allows XML comments <!-- -->. So in the XML Source view will look like;<br />
<br />
<span style="color: purple;"><span style="color: purple;"><!--subform usehref=".\JasmineSpec.xdp#som($template.#subform.JasmineSpec)"></subform--></span></span><br />
<br />
I am using the Jasmine framework version 2.0, the latest is 2.2 but I have not been successful in getting later version to run in the Acrobat environment, again because of the differences in the <span style="font-family: Courier New;">app.setTimeOut()</span> function. I'm not sure what I am missing but 2.0 has provided enough functionality for me so far.<br />
<br />
<br />
<br />
<br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com1tag:blogger.com,1999:blog-7970679050025899967.post-10323070097518069742015-04-23T00:00:00.001-07:002020-12-30T15:19:50.560-08:00Adobe Dialog Manager (ADM) in Acrobat JavaScript: insertEntryInList, removeAllEntriesFromList and insertSeparatorEntryInListThis sample demonstrates the undocumented list methods available when using Adobe Dialog Manager (ADM) in Acrobat JavaScript, also called a custom dialog using the <span style="font-family: "Courier New", Courier, monospace;">app.execDialog()</span> method.<br />
<br />
These methods, on the <a href="http://help.adobe.com/livedocs/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?href=JS_Dev_Tools.72.1.html#1515775&accessible=true">JavaScript API > Dialog object</a>, are;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">insertEntryInList(<em>object</em></span><span style="font-size: x-small;">)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">removeAllEntriesFromList(</span><span style="font-size: x-small;"><span style="color: black; font-size: x-small;"><em>item_id</em></span></span><span style="font-size: x-small;">)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"></span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New", Courier, monospace;">insertSeparatorEntryInList(<span style="font-size: x-small;"><span style="color: black; font-size: x-small;"><em>item_id</em></span></span><span style="font-size: x-small;">)</span></span><br />
<br />
</span><span style="font-size: small;">As they are undocumented they could disappear in future releases of Adobe Reader but they are also used by Reader itself, if you open a JavaScript debugger console and type IWDistributionServer you will see the source code of one of the JavaScript functions that use it.</span><br />
<br />
This sample implements a ListPicker control, <a href="https://drive.google.com/uc?export=download&id=1yoUcHSLMn7CS2pFURQFJDar7mtwo5HBn">ListPicker.pdf</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-dLefE-ZIuvk/VSHVriDTpGI/AAAAAAAAARI/6yAUgATrIpI/s1600/ListPicker.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-dLefE-ZIuvk/VSHVriDTpGI/AAAAAAAAARI/6yAUgATrIpI/s1600/ListPicker.PNG" height="155" width="320" /></a></div>
<br />
Once the selections are made the you can move a separator line (the blue line in the selection list) up and down.<br />
<br />
The separator line can be added to a list with the load method by using the property name "\-" but seems to always appears at the beginning, so the code which you would expect to add a separator as the second item.<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">dialog.load({ </span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"LST1"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> { </span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"abc"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">-</span></span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">1</span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">,</span></span><span style="font-size: x-small;"> </span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"\\-"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">-</span></span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">2</span></span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">,</span></span><span style="font-size: x-small;"> </span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"def"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">-</span></span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">3</span></span><span style="font-size: x-small;"> } })</span></span><br />
<br />
Adds it as the first.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-VDfd4EuoLBA/VSHYb4YCTwI/AAAAAAAAARU/AqcpRMrmyhc/s1600/separator.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-VDfd4EuoLBA/VSHYb4YCTwI/AAAAAAAAARU/AqcpRMrmyhc/s1600/separator.PNG" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
To achieve the effect we wanted we would need to use;<br />
<span style="font-size: x-small;"></span><br />
<span style="font-size: x-small;"> <span style="font-family: "Courier New", Courier, monospace;">dialog.insertEntryInList({ </span></span><span style="font-family: "Courier New", Courier, monospace;"><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"LST1"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> { </span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"abc"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">-</span></span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">1</span></span><span style="font-size: x-small;"> } })</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">
</span><span style="font-size: x-small;">dialog.insertSeparatorEntryInList(</span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"LST1"</span></span><span style="font-size: x-small;">); </span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">
</span><span style="font-size: x-small;">dialog.insertEntryInList({ </span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"LST1"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> { </span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">"def"</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">:</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">-</span></span><span style="color: #ff6600; font-size: x-small;"><span style="color: #ff6600; font-size: x-small;">3</span></span><span style="font-size: x-small;"> } })</span></span><br />
<br />
BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com1tag:blogger.com,1999:blog-7970679050025899967.post-63477134338599428252015-04-16T00:00:00.001-07:002020-12-30T15:22:03.721-08:00Adobe Dialog Manager (ADM) in Acrobat JavaScript: progress_barThis sample demonstrates the undocumented <span style="color: orange; font-family: "Courier New", Courier, monospace;">progress_bar</span> control when using Adobe Dialog Manager (ADM) in Acrobat JavaScript, also called a custom dialog using the <span style="font-family: "Courier New", Courier, monospace;">app.execDialog()</span> method.<br />
<br />
The control can be defined with the following code; <br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"> type<span style="color: blue;">:</span> <span style="color: orange;">"progress_bar"</span><span style="color: blue;">,</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"> width<span style="color: blue;">:</span> <span style="color: orange;">100</span><span style="color: blue;">,</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"> height<span style="color: blue;">:</span> <span style="color: orange;">22</span><span style="color: blue;">,</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"> item_id<span style="color: blue;">:</span> <span style="color: orange;">"PBAR"</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"> } </span><br />
<br />
Updates to the position of the progress bar can be made with <br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">dialog.load({<span style="color: orange;">"PBAR"</span><span style="color: blue;">:</span> (100 <span style="color: blue;">/</span> this.fieldCount) <span style="color: blue;">*</span> validFieldCount}); </span><br />
<br />
This code sets the progress bar to a value between 0 and 100 depending on how many valid fields there are. <br />
<br />
I started playing with the progress bar control when attempting to develop a timed dialog using <span style="font-family: "Courier New", Courier, monospace;">app.setInterval()</span> but the timer seems to be paused when a dialog is display (as it is if a menu is opened) <br />
<br />
Still there are some other uses and this sample uses a progress bar to show how much of the dialog is complete and another to indicate the password strength. <br />
<br />
<a href="https://drive.google.com/uc?export=download&id=1Odc1nRMaHCgASGqruNapg15rNR9Pl3Id">Progress_Bar.pdf</a> BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-25427589299007650792015-04-09T00:00:00.000-07:002015-04-09T00:00:05.765-07:00Adobe LiveCycle Designer Tip #9 - The JavaScript console and string literalsOne of the little mysteries with working Acrobat JavaScript is how the JavaScript console handles string literals.<br />
<br />
If you open Acrobat and then the JavaScript console, (using Ctrl-J) and type<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">'abc'.length</span> .. we get a response of 3<br />
<br />
and<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">“abc”.length</span> .. also gives a response of 3<br />
<br />
But if we are using the JavaScript console when performing a PDF Preview from LiveCycle Designer then<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">'abc'.length</span> .. still gives us 3<br />
<br />
but<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">“abc”.length</span> .. returns undefined<br />
<br />
Even worse <br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">'a"b"c'.length</span> .. also returns undefined, (that is a double quote within single quotes)<br />
<br />
So it seems we can’t use double quotes at all, but we can you just need to escape them (even though JavaScript should not require us to), so<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">'a\"b\"c'.length</span> .. returns 5<br />
<br />
This doesn’t cause problems daily but every now and then … maybe if I’m having trouble with a SOM expression involving a predicate, say something like<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">Content.dataNode.resolveNode('$.Location.[Level == "Lead"]')</span>BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-30999415303061622482015-04-02T00:00:00.000-07:002015-04-02T00:00:07.041-07:00Windows Search and XDP filesBy default the Windows Search will only pick up the file properties of XDP files. But since XDP files are really just XML files we can set the search filter handler to the XML Filter and then our search will look in the element and attribute values of the XDP file.<br />
<br />
To do this we need to edit the Registry. If we look at the registry key for the .xml file type (which has a key of HKEY_CLASSES_ROOT\.xml) we see<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-2sqxF2tl_a8/VQFou73_zCI/AAAAAAAAAQo/hUkmHVkWvzI/s1600/.XML%2BReg.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-2sqxF2tl_a8/VQFou73_zCI/AAAAAAAAAQo/hUkmHVkWvzI/s1600/.XML%2BReg.PNG" height="60" width="400" /></a></div>
<br />
To make Windows Search treat XDP files like XML all we need to do copy the PersistentHandler key with a default value of the GUID for the XML Filter which is {7E9D8D44-6926-426F-AA2B-217A819A5CCE} to the XDP class key HKEY_CLASSES_ROOT\.xdp.<br />
<br />
Once we have done that, if you go to Index Options, select Advanced ... File Types and scroll down to XDP you will see the XML Filter is being used.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-z69Kn5yD6R4/VQFrHE0P3II/AAAAAAAAAQ0/2y71Qc31dNI/s1600/IndexOptions.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-z69Kn5yD6R4/VQFrHE0P3II/AAAAAAAAAQ0/2y71Qc31dNI/s1600/IndexOptions.PNG" height="320" width="318" /></a></div>
<br />
Make sure you have the "Index Properties and File Contents" selected, then go back to Index Settings tab and click the Rebuild button ... wait several hours and your searches will now include the contents of the XDP files.<br />
<br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-2939651357410273662015-03-26T00:00:00.000-07:002015-03-26T00:00:08.879-07:00Handling a full stop in a XML element name<br />
The “.” (full stop) character is valid in an XML name, this means there can be cases were you need to escape a full stop in a SOM expression.<br />
<br />
This is the default format when using SQL Server and the FOR XML AUTO option and the table has <br />
a schema, you will end up with XML like;<br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;"><</span></span><span style="color: #a31515; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">ClientMgmt</span></span><span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">><o:p></o:p></span></span></div>
<span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;"><</span></span><span style="color: #a31515; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">ClientMgmt.ClientDetails</span></span><span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;"> </span></span><span style="color: red; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">name</span></span><span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">=</span></span><span style="font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">"</span><span style="color: blue;"><span style="font-size: x-small;">...</span></span><span style="font-size: x-small;">"</span><span style="color: blue;"><span style="font-size: x-small;"> /></span></span><span style="font-size: x-small;"> <o:p></o:p></span></span><br />
<span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;"><</span></span><span style="color: #a31515; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">ClientMgmt.ClientDetails</span></span><span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;"> </span></span><span style="color: red; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">name</span></span><span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="font-size: x-small;">=<span style="font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="color: black; font-size: x-small;">"</span><span style="color: blue;"><span style="font-size: x-small;">...</span></span><span style="color: black; font-size: x-small;">"</span></span></span></span><span style="font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;"><span style="color: blue;"><span style="font-size: x-small;">
/><o:p></o:p></span></span></span><br />
<span style="font-size: x-small;"><span style="color: blue; font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU; mso-no-proof: yes;">…</span><o:p></o:p></span><br />
<br />
In a SOM Expression the full stop needs to be escaped with a “\” (backslash), when we put this in JavaScript code we again need to escape the backslash, so end up with three backslash characters.<br />
<div class="MsoNormal" style="margin: 1em 0cm;">
<span style="font-family: "Courier New"; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU;"><span style="font-size: x-small;">$data.resolveNodes(</span><span style="color: #ff9900;"><span style="font-size: x-small;">'ClientMgmt.ClientMgmt\\\.ClientDetails[*]')</span></span></span><o:p></o:p></div>
Interestingly when trying the same in the Acrobat JavaScript debugger you need to use four backslash characters.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-15315608765117342812015-03-19T00:00:00.001-07:002020-12-30T15:25:31.123-08:00Going deeper with floating fieldsFloating fields allow variable text to be inserted within a text object. A floating field is referenced within a rich text field using XFA extension to the xHTML <span> element, e.g.<br />
<br />
As inserted by the LiveCycle Designer Insert ... Floating Field command you will get something like this in the XML Source<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><</span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">span</span></span><span style="font-size: x-small;"> </span><span style="color: #0080ff; font-size: x-small;"><span style="color: #0080ff; font-size: x-small;">xfa:embedType</span></span><span style="font-size: x-small;">="</span><span style="color: teal; font-size: x-small;"><span style="color: teal; font-size: x-small;">uri</span></span><span style="font-size: x-small;">" </span><span style="color: #0080ff; font-size: x-small;"><span style="color: #0080ff; font-size: x-small;">xfa:embedMode</span></span><span style="font-size: x-small;">="</span><span style="color: teal; font-size: x-small;"><span style="color: teal; font-size: x-small;">raw</span></span><span style="font-size: x-small;">" </span><span style="color: #0080ff; font-size: x-small;"><span style="color: #0080ff; font-size: x-small;">xfa:embed</span></span><span style="font-size: x-small;">="</span><span style="color: teal; font-size: x-small;"><span style="color: teal; font-size: x-small;">#floatingField007456</span></span><span style="font-size: x-small;">"/></span></span><br />
<span style="font-size: x-small;"></span><br />
<span style="font-size: x-small;"><span style="font-size: small;">The full XFA syntax for a floating field is;</span></span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span xmlns:xfa="</span><a href="http://www.xfa.org/schema/xfa-data/1.0/"><span style="font-family: "Courier New", Courier, monospace;">http://www.xfa.org/schema/xfa-data/1.0/</span></a><span style="font-family: "Courier New", Courier, monospace;">"<br /> xfa:embedType="uri | som"<br /> xfa:embed="<SOM expr> | <uri>"<br /> xfa:embedMode="raw | formatted"/></span><br />
<h3>
embedType</h3>
When the embedType has a value of "uri" then the embed value will be the id of the floating field, prefixed with a "#" symbol.<br />
<br />
But you can see from the syntax that there are some other options available. Sometimes we might create a floating field bind it to our data connection just to display the value embedded in some text. Say the floating field was bound to <span style="color: teal; font-family: "Courier New"; font-size: 9pt; mso-ansi-language: EN-AU; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-AU;">$data.formData.firstName</span> then we could change our span element to reference the data connection directly, in which case we don't need the floating field at all.<br />
<br />
Another situation you may need to use a SOM expression in an embedded field is when you have multiple levels of repeating data, such as a list of countries within which we have a list of cities<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-SVKauX-bW8M/VPvelezlGwI/AAAAAAAAAQU/1s36OPlwefc/s1600/DataConnection.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-SVKauX-bW8M/VPvelezlGwI/AAAAAAAAAQU/1s36OPlwefc/s1600/DataConnection.png" height="142" width="320" /></a></div>
<br />
If I wanted to use a floating field to display the country element within the repeating city element, there is no way Designer can make the reference. Designer will give you a binding expression like $record.counties.country, which will always return you the first country. In this case we can again change the embedType to "som" but use a form object SOM expression, something like;<br />
<br />
<span lang="EN-US" style="font-family: "Courier New"; mso-ansi-language: EN-US; mso-bidi-font-size: 10.0pt; mso-fareast-language: EN-AU;"><span style="font-size: x-small;"><</span><span style="color: red;"><span style="font-size: x-small;">span</span></span><span style="font-size: x-small;"> </span><span style="color: #0080ff;"><span style="font-size: x-small;">xfa:embedType</span></span><span style="font-size: x-small;">="</span><span style="color: teal;"><span style="font-size: x-small;">som</span></span><span style="font-size: x-small;">" </span><span style="color: #0080ff;"><span style="font-size: x-small;">xfa:embedMode</span></span><span style="font-size: x-small;">="</span><span style="color: teal;"><span style="font-size: x-small;">raw</span></span><span style="font-size: x-small;">" </span><span style="color: #0080ff;"><span style="font-size: x-small;">xfa:embed</span></span><span style="font-size: x-small;">="</span><span style="color: teal;"><span style="font-size: x-small;">countries.country</span></span><span style="font-size: x-small;">"/></span></span><o:p></o:p><br />
<br />
This will resolve to the form object with the SOM expression countries.country, which should be the right country for the city we are processing.<br />
<br />
<h3>
embedMode</h3>
By default the embedMode is set to "raw", which means only the floating fields value is inserted, all font formatting is taken from the surrounding text. A value o<span style="font-family: "Arial",sans-serif; font-size: 10pt; mso-ansi-language: EN-AU; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 12.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">f </span><span lang="EN-US" style="color: teal; font-family: "Courier New"; font-size: 10pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-AU;">formatted</span><span lang="EN-US" style="font-family: "Arial",sans-serif; font-size: 10pt; mso-ansi-language: EN-AU; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 12.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;"> </span><span style="font-family: "Arial",sans-serif; font-size: 10pt; mso-ansi-language: EN-AU; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 12.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">f</span>o<span style="font-family: "Arial",sans-serif; font-size: 10pt; mso-ansi-language: EN-AU; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 12.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">r </span><span lang="EN-US" style="color: #0080ff; font-family: "Courier New"; font-size: 9pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-AU;">embedMode</span><span lang="EN-US" style="font-family: "Arial",sans-serif; font-size: 10pt; mso-ansi-language: EN-AU; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 12.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;"> </span><span style="font-family: "Arial",sans-serif; font-size: 10pt; mso-ansi-language: EN-AU; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 12.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">m</span>eans the font attributes of the inserted text are taken from the inserted field, which can be useful if we need to dynamically update them as in this sample, <a href="https://drive.google.com/uc?export=download&id=1l33wr3mMWJHRMfKkeRw0_TOki2kJFlsK">FloatingFields.pdf</a>.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-59186465752461302322015-03-12T00:00:00.000-07:002015-03-12T03:39:38.265-07:00Adobe LiveCycle Designer Tip #8 - Bringing colour to your workspace (and other settings)I recently received an upgraded computer, which meant I had to re-install LiveCycle Designer ... and find all my settings again.<br />
<br />
<h3>
Tools ... Options ... Document Handling</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-5xdS_1etBnE/VPqjQKHgejI/AAAAAAAAAPM/yFIBYOvJngk/s1600/DocumentHandling.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-5xdS_1etBnE/VPqjQKHgejI/AAAAAAAAAPM/yFIBYOvJngk/s1600/DocumentHandling.PNG" height="278" width="320" /></a></div>
<br />
Increase the number of files in the <strong>Recently Used File List</strong> to 10. This seems to be the maximum, although there is no error when a higher number is entered the value will not be saved.<br />
<br />
Set the <strong>Create Backup Copy on Save</strong>, this will create a _BAK.pdf file (or a _BAK.xdp file) which gives you a chance to recover your work if Designer crashes on you. The disadvantage of setting this option is when you edit a fragment the _BAK file will be created and the fragment will be duplicated when viewed in the fragment library. Another way you can recover your work if Designer crashes to look for a PDF file in your Windows %temp% directory with some random looking name <span style="font-family: "Courier New", Courier, monospace;">_1f7o26cap4d25e8q1t.pdf</span> this is the file that is created whenever you perform a PDF Preview<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="font-family: inherit; font-size: small;">.</span></span><br />
<br />
<h3>
Tools ... Options ... Workspace</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-i9ub3b7FFz0/VPql0fTF6GI/AAAAAAAAAPY/KktinQ4yP_c/s1600/Workspace.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-i9ub3b7FFz0/VPql0fTF6GI/AAAAAAAAAPY/KktinQ4yP_c/s1600/Workspace.png" height="193" width="320" /></a></div>
<br />
Under <strong>JavaScript Syntax Formatting </strong>... select a custom color for strings and numbers, I use an orange color. I used to have a boss who set his to red, he never wanted to see any red. I'm not that strict so set mine to an orange. The idea is to make you think if these values would be better off in a form variable or a dataset.<br />
<br />
Select the <strong>Show Line Numbers</strong> checkbox, any runtime errors will refer to a line number so showing line numbers makes it easier to find the right line. Just make sure there are no blank lines at the start of your script as these aren't counted when line numbers are displayed in error messages.<br />
<br />
<h3>
Tools ... Options ... Data Binding</h3>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-2OCZy4eelTQ/VPqovJJYYwI/AAAAAAAAAPk/U9s4YmYX4fU/s1600/DataBinding.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-2OCZy4eelTQ/VPqovJJYYwI/AAAAAAAAAPk/U9s4YmYX4fU/s1600/DataBinding.PNG" height="280" width="320" /></a></div>
Set the <strong>Show Dynamic Properties</strong> checkbox, this will enable the option to bind values in a drop down to the data connection<br />
<br />
Set the <strong>Default Binding for New Subforms</strong> to "No Data Binding"<br />
<h3>
Window ... Drawing Aids</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-l0jPkMltfkc/VPqp5HuBxHI/AAAAAAAAAPs/ethIF-IOMrk/s1600/DrawingAids.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-l0jPkMltfkc/VPqp5HuBxHI/AAAAAAAAAPs/ethIF-IOMrk/s1600/DrawingAids.png" height="314" width="320" /></a></div>
<br />
Deselect the <strong>Snap to Grid</strong> option to allow finer control over the form objects, typically I use flowed subforms but even with a positional subform it is usually easier to align with another object, under the Layout menu or learn the keyboard shortcuts, Ctrl-LeftArrow to align a group of fields on there left boundary, etc.<br />
<br />
<h3>
Tools ... Keyboard Shoutcuts</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-uI8KF-LNTTQ/VPtsbAFNDnI/AAAAAAAAAQA/IDbONs1CGVk/s1600/KeyboardShortcuts.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-uI8KF-LNTTQ/VPtsbAFNDnI/AAAAAAAAAQA/IDbONs1CGVk/s1600/KeyboardShortcuts.png" height="320" width="250" /></a></div>
<br />
Add Ctrl-Shift-w for <strong>Warp in Subform </strong>and Ctrl-Shift-u for <strong>Unwarp Subform.</strong> The default keyboard shortcuts are listed in <a href="http://help.adobe.com/en_US/livecycle/11.0/DesignerHelp/WS92d06802c76abadb-95d0453129b8b01a84-7fff.2.html">Using Designer ES4 / Working with the Keyboard / Default keyboard shortcuts </a><br />
<br />
<br />
<br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-73113472479189692092015-03-05T14:02:00.001-08:002020-12-30T20:48:46.799-08:00SOM Expressions with Relative IndexesMost SOM expressions I work with have an absolute index number, something like form1[0].[0].Table1[0].Row1[0].TextField1[0] where all the numbers within the square brackets are absolute numbers. But these numbers can be relative, that is have a positive or negative sign. So if I was on TextField1 of row 2 and wanted to reference TextField1 of row 1 I could use a SOM expression like;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">Row1.resolveNode('Row1[-1].TextField1');</span><br />
<br />
Similarly if I have a series of fields with the same name and so have different indexes, say TextField[0], TextFIeld[1] etc, I can reference the next field, in document order, called TextField with a SOM expression <br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">this.resolveNode('TextField[+1]').rawValue</span><br />
<br />
We can also refer to the next field without knowing it's name using the class name reference (that is with a "#" character).<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">this.resolveNode('#field[+1]').somExpression</span><br />
<br />
or the next button<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;">this.resolveNodes('#field.(ui.oneOfChild.className == "button")').item(1).somExpression</span><br />
<br />
This sample gives examples of these expressions and uses a relative SOM expression to calculate a running total in a table.<br />
<br />
<a href="https://drive.google.com/uc?export=download&id=1CzYjiIHis6OC7HLB3C7dQtYqlMHCVhwB">RelativeIndex.pdf</a><br />
<br />
BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-51514127934674305512015-02-14T22:53:00.003-08:002020-12-30T21:56:13.420-08:00Custom Properties<span style="font-family: inherit; font-size: x-small;">The XFA specification defines customs properties that can be store in a field, exclGroups (or radio buttons) or subforms under the <span style="font-family: "Courier New", Courier, monospace;"><desc></span> and <span style="font-family: "Courier New", Courier, monospace;"><extras></span> elements. These allow us to write scripts that process a form but allow the individual fields and subforms to control that processing. The example used here is a script that sets all the fields to their default value, except if an <span style="font-family: "Courier New", Courier, monospace;">allowResetData</span> property is set to false. Other scenarios might be setting all fields to read only, except some, or some have additional processing, validation frameworks, setting min/max values, etc.</span><br />
<span style="font-family: inherit; font-size: x-small;"><br />There doesn’t seem to be much difference between using the <span style="font-family: "Courier New", Courier, monospace;"><desc></span> or <span style="font-family: "Courier New", Courier, monospace;"><extras></span> elements but I tend to use <span style="font-family: "Courier New", Courier, monospace;"><desc></span> as the names and values are shown in the Info palette.
<br />
</span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: inherit; font-size: x-small;"><a href="http://3.bp.blogspot.com/-hfPRKqmlW9s/VN7QocXiP-I/AAAAAAAAAOc/0j0K2aEkazE/s1600/InfoPalette.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-hfPRKqmlW9s/VN7QocXiP-I/AAAAAAAAAOc/0j0K2aEkazE/s1600/InfoPalette.png" height="115" width="320" /></a></span>
</div>
<div align="left" class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: inherit; font-size: x-small;">
The <span style="font-family: "Courier New", Courier, monospace;"><desc></span> element is also were the <span style="font-family: "Courier New", Courier, monospace;"><span style="color: blue;"><span style="font-size: small;"><</span></span><span style="color: #a31515;"><span style="font-size: small;">xs</span></span><span style="color: blue;"><span style="font-size: small;">:</span></span><span style="color: #a31515;"><span style="font-size: small;">annotation</span></span></span><span style="color: blue;"><span style="font-size: small;"><span style="font-family: "Courier New", Courier, monospace;">></span> </span><span style="color: black; font-size: x-small;">information is stored is you are using a XML Schema for your data connection.</span></span></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: black; font-family: inherit; font-size: x-small;"><span style="color: blue;"></span></span> </div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: inherit; font-size: x-small;">The XFA for a field with this custom property would then look like;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: x-small;"></span> </div>
<span style="font-size: x-small;"> </span><span style="font-size: xx-small;"><span style="font-family: "Courier New", Courier, monospace;"><</span><span style="font-family: "Courier New", Courier, monospace;"><span style="color: red;"><span style="color: red;">field</span></span> <span style="color: #0080ff;"><span style="color: #0080ff;">name</span></span>="<span style="color: teal;"><span style="color: teal;">TextField1</span></span>" <span style="color: #0080ff;"><span style="color: #0080ff;">w</span></span>="<span style="color: teal;"><span style="color: teal;">62mm</span></span>" <span style="color: #0080ff;"><span style="color: #0080ff;">h</span></span>="<span style="color: teal;"><span style="color: teal;">9mm</span></span>"></span></span><br />
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> <<span style="color: red;"><span style="color: red;">desc</span></span>></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> <<span style="color: red;"><span style="color: red;">boolean</span></span> <span style="color: #0080ff;"><span style="color: #0080ff;">name</span></span>="<span style="color: teal;"><span style="color: teal;">allowResetData</span></span>">1</<span style="color: red;"><span style="color: red;">boolean</span></span>></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> </<span style="color: red;"><span style="color: red;">desc</span></span>></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> <<span style="color: red;"><span style="color: red;">ui</span></span>></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> <<span style="color: red;"><span style="color: red;">textEdit</span></span>/></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> </<span style="color: red;"><span style="color: red;">ui</span></span>></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> ...</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"></<span style="color: red;"><span style="color: red;">field</span></span>></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: x-small;"></span> </div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: inherit; font-size: x-small;">There is no support for updating these values in LiveCycle Designer but I will include two macros that can be used to update the <span style="font-family: "Courier New", Courier, monospace;">allowResetData</span> property and hopefully can be used as a guide for updating your own properties … or you could just edit the XML Source window. <br />
<br />The data stored under a <span style="font-family: "Courier New", Courier, monospace;"><desc></span> element can be typed, so JavaScript references are returned in properties with the appropriate data type. The exception is the date/time related elements that are returned as strings. <br />
<br />
</span></div>
<br />
<span style="font-family: inherit; font-size: x-small;"><span style="font-size: large;">
</span><span style="font-size: large;">
</span><br />
<table style="border-collapse: collapse; border-color: rgb(170, 188, 254); border-spacing: 0; table-layout: fixed; width: 100%;">
<thead>
<tr>
<th style="border: 1px solid rgb(170, 188, 254); padding: 2px; text-align: left; width: 25%;"><div style="text-align: left;">
<span style="font-size: large;">desc element</span></div>
</th><th style="border: 1px solid rgb(170, 188, 254); padding: 2px; text-align: left; width: 25%;"><div style="text-align: left;">
<span style="font-size: large;">JavaScript</span><br />
<span style="font-size: large;">Data Type</span></div>
</th><th style="border: 1px solid rgb(170, 188, 254); padding: 2px; text-align: left;"><div style="text-align: left;">
<span style="font-size: large;">Value Range</span></div>
</th>
</tr>
</thead>
<tbody>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">boolean</span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Boolean</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">0 – false, 1 – true</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">date</span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">String</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"> </td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">dateTime</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"></span><br /></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">String</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"> </td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">decimal</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Number</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">For integers;<br />
9007199254740992 to -9007199254740992;<br />
(Same as JavaScript, that is 2<sup>53</sup>)<br />
For floats<br />
1.79E+308 to 1E-15 (max 15 decimal digits if specified by the fracDigits attribute e.g.<br />
<span style="font-family: "Courier New"; mso-ansi-language: EN-AU; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-AU;"><span style="font-size: xx-small;"><<span style="color: red;">decimal</span> <span style="color: #0080ff;">name</span>="<span style="color: teal;">Decimal</span>"
<span style="color: #0080ff;">fracDigits</span>="<span style="color: teal;">15</span>"/></span></span>, <br />
Otherwise defaults to 2 decimal places</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: black;"><span style="color: blue;">exData</span></span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">String</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"> </td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">float</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Number</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">9007199254740992 to -9007199254740992;<br />
<em>(Same as JavaScript)</em><br />
For floats<br />
1.79E+308 to 1E-08 (max 8 decimal digits)</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">image</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">String</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">Prints the number 2 in a width of 5 characters with "0" characters padding</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">integer</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Number</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">2147483647 to -2147483647<br />
<em>Attempting to assign a number outside this range raises an "Operation failed." GeneralError exception</em></td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">text</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">String</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"> </td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">time</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">String</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"> </td>
</tr>
</tbody></table>
</span><span style="font-family: inherit; font-size: x-small;">
</span><span style="font-family: inherit; font-size: x-small;">
<br /><br />
I haven’t seen any limits documented, these are the values I have found by playing around. Also remember for decimal and float values that exceed the maximum integer value then the precision starts to fail like all usual float values, e.g.</span><br />
<span style="font-family: inherit; font-size: x-small;"><br />9007199254740992 + 1 = 9007199254740992<br />9007199254740994 + 2 = 9007199254740994<br />9007199254740992 + 3 = 9007199254740996</span><br />
<span style="font-family: inherit; font-size: x-small;"></span><br />
<span style="font-family: inherit; font-size: x-small;">More about float and decimal values here, <a href="http://en.wikipedia.org/wiki/Double-precision_floating-point_format" target="_blank">http://en.wikipedia.org/wiki/Double-precision_floating-point_format</a></span><br />
<br />
<span style="font-size: x-small;">A value under a <span style="font-family: "Courier New", Courier, monospace;"><desc></span> element value can be referenced directly in JavaScript using <span style="font-family: "Courier New", Courier, monospace;">TextField1.desc.allowResetData.value</span> but if the property does not exist on the form object you will get a “<span style="font-family: "Courier New", Courier, monospace;">Invalid property get operation; desc doesn't have property 'allowResetData'</span>” exception. To check if a property exists use the namedItem() method, <span style="font-family: "Courier New", Courier, monospace;">TextField1.desc.nodes.namedItem("allowResetData")</span>, this will return null if the property does not exist or an object with a value property if it does.</span><br />
<span style="font-size: x-small;"></span><br />
<span style="font-size: x-small;">So now the JavaScript function to process the form (or part of the form) could look like this;</span><br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;">function</span></span> resetData(node)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">{</span><br />
<span style="font-size: x-small;"> </span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> function</span></span> pushResetDataList(node)</span></span><br />
<span style="color: blue; font-family: Courier New; font-size: xx-small;"> </span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">{</span><br />
<span style="color: blue; font-family: Courier New; font-size: xx-small;"> </span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"><span style="color: blue;">var</span></span> allowResetData <span style="color: blue;"><span style="color: blue;">=</span></span> node.desc.nodes.namedItem(<span style="color: #ff6600;"><span style="color: #ff6600;">"allowResetData"</span></span>);</span><br />
<span style="color: green; font-family: Courier New; font-size: xx-small;"> // default is too allow reset</span><br />
<span style="color: blue; font-family: Courier New; font-size: xx-small;"> </span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"><span style="color: blue;">if</span></span> (allowResetData <span style="color: blue;"><span style="color: blue;">===</span></span> <span style="color: blue;"><span style="color: blue;">null</span></span> <span style="color: blue;"><span style="color: blue;">||</span></span> allowResetData.value)</span><br />
<span style="color: blue; font-family: Courier New; font-size: xx-small;"> </span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">{</span><br />
<span style="color: blue; font-family: Courier New; font-size: xx-small;"> </span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">resetDataList.push(node.somExpression);</span><br />
<span style="color: blue; font-family: Courier New; font-size: xx-small;"> </span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span></span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> function</span></span> resetDataInner(node)</span></span>
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"> </span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"> {</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"> i</span></span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace;"><span style="color: blue;"><span style="color: blue;">f</span></span> (node.className <span style="color: blue;"><span style="color: blue;">===</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">"exclGroup"</span></span> <span style="color: blue;"><span style="color: blue;">&&</span></span> <span style="color: blue;"><span style="color: blue;">!</span></span>node.isNull) <span style="color: green;"><span style="color: green;">// don't reset fields that are null</span></span></span></span></span></span></span><br />
<span style="font-size: xx-small;"><span style="font-family: "Courier New", Courier, monospace;"><span style="color: blue;"><span style="color: blue;"><span style="color: black;"> </span><span style="font-family: "Courier New", Courier, monospace;">{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>pushResetDataList(node);</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: blue;"><span style="color: blue;"><span style="color: black;"> </span>else</span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: blue;"><span style="color: blue;"><span style="color: black;"> </span>if</span></span> (node.className <span style="color: blue;"><span style="color: blue;">===</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">"field"</span></span>)</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: blue;"><span style="color: blue;"><span style="color: black;"> </span>if</span></span> (node.ui.oneOfChild.className <span style="color: blue;"><span style="color: blue;">!==</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">"button"</span></span> <span style="color: blue;"><span style="color: blue;">&&</span></span> <span style="color: blue;"><span style="color: blue;">!</span></span>node.isNull) <span style="color: green;"><span style="color: green;">// buttons always null</span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>pushResetDataList(node);</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>}</span><br />
<span style="color: black;"> </span>}<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: blue;"><span style="color: blue;"><span style="color: black;"> </span>else</span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="color: black;"> </span>for </span></span></span></span></span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">(<span style="color: blue;"><span style="color: blue;">var</span></span> i <span style="color: blue;"><span style="color: blue;">=</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">0</span></span>; i <span style="color: blue;"><span style="color: blue;"><</span></span> node.nodes.length; i<span style="color: blue;"><span style="color: blue;">++</span></span>)</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>{</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> <span style="color: black;"> </span> var</span></span> nextNode <span style="color: blue;"><span style="color: blue;">=</span></span> node.nodes.item(i);</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> <span style="color: black;"> </span> if</span></span> (nextNode.className <span style="color: blue;"><span style="color: blue;">===</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">"instanceManager"</span></span>)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span></span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> <span style="color: black;"> </span>if</span></span> (nextNode.count.toString() <span style="color: blue;"><span style="color: blue;">!==</span></span> nextNode.occur.min)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"><span style="color: black;"> </span> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>nextNode.setInstances(nextNode.occur.min); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>}</span><br />
<span style="color: blue;"><span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: xx-small;"> <span style="color: black;"> </span>else</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"><span style="color: black;"> </span> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> <span style="color: black;"> </span> if</span></span> (nextNode.className <span style="color: blue;"><span style="color: blue;">===</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">"variables"</span></span>)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> <span style="color: black;"> </span> var</span></span> scriptObject <span style="color: blue;"><span style="color: blue;">=</span></span> nextNode.resolveNode(<span style="color: #ff6600;"><span style="color: #ff6600;">"Script"</span></span>);</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> <span style="color: black;"> </span> if</span></span> (scriptObject <span style="color: blue;"><span style="color: blue;">&&</span></span> scriptObject.hasOwnProperty(<span style="color: #ff6600;"><span style="color: #ff6600;">"resetData"</span></span>))</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"><span style="color: black;"> </span> </span>scriptObject.resetData();</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>}</span><br />
<span style="color: blue;"><span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: xx-small;"> <span style="color: black;"> </span> else</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"><span style="color: black;"> </span> if</span></span> (nextNode.isContainer <span style="color: blue;"><span style="color: blue;">&&</span></span> nextNode.className <span style="color: blue;"><span style="color: blue;">!==</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">"draw"</span></span>)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>resetDataInner(nextNode);</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> <span style="color: black;"> </span> </span>}<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span></span><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> var</span></span> resetDataList <span style="color: blue;"><span style="color: blue;">=</span></span> [];</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>resetDataInner(node);</span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> if</span></span> (resetDataList.length <span style="color: blue;"><span style="color: blue;">></span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">0</span></span>)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>xfa.host.resetData(resetDataList.join(<span style="color: #ff6600;"><span style="color: #ff6600;">","</span></span>));</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">}</span> </span></div>
<span style="font-size: x-small;"></span><br />
<span style="font-size: x-small;"></span>All subforms can have a script object and this resetData function looks for a script object called “Script” that contains a JavaScript function called “resetData” and if found executes it , the code under the nextNode.className === “variables”.<br />
<br />
<div style="line-height: 1;">
<span style="font-size: x-small;"></span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> var</span></span> scriptObject <span style="color: blue;"><span style="color: blue;">=</span></span> nextNode.resolveNode(<span style="color: #ff6600;"><span style="color: #ff6600;">"Script"</span></span>);</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: xx-small;"><span style="color: blue;"><span style="color: blue;"> if</span></span> (scriptObject <span style="color: blue;"><span style="color: blue;">&&</span></span> scriptObject.hasOwnProperty(<span style="color: #ff6600;"><span style="color: #ff6600;">"resetData"</span></span>))</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>scriptObject.resetData();</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><span style="color: blue;"> </span>}</span></div>
<br />
This allows parts of the form to perform any custom operations required when a form is reset. This example (<a href="https://drive.google.com/uc?export=download&id=1LMSw7JkrPWNGLcX4zN6TgPkR1q5FnG-w">CustomProperties.pdf</a>) uses this function to remove a file that has been attached to the form.<br />
<br />
I use two macros for setting and clearing <span style="font-family: Courier New; font-size: x-small;">allowResetData</span><span style="font-size: x-small;"> </span>flag. Once installed you will be able to select the appropriate form objects and run a macro instead of editing the XML Source. To run select Tools … Macros … “Set allowResetData Flag to False” or Tools … Macros … “Clear allowResetData Flag”. The macros and macro.xml configuration file are in the zip file (<a href="https://drive.google.com/uc?export=download&id=1_k00X0AduHI4aseSeWXdZGUYNzKfQEJw">CustomProperties.Macros.zip</a>).<br />
<br />
If you haven’t written or installed a macro before then refer to the help page. <a href="http://help.adobe.com/en_US/livecycle/10.0/DesignerHelp/WS3041177a02dcf48e2f8c933d12daa5a53a3-8000.html" target="_blank">Designer 10 - Macros</a><br />
<br />
The <span style="font-family: "Courier New", Courier, monospace;"><exData></span> element can be used to store rich text and be used to populate a Text control like; <br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">Text1.value.exData.loadXML(TextField1.desc.ExData.saveXML()</span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">,</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">true,</span></span><span style="font-size: x-small;"> </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">true</span></span><span style="font-size: x-small;">);</span></span><br />
<br />
Likewise the <span style="font-family: "Courier New", Courier, monospace;"><image></span> custom property can be used to store image and used to populate an image control like; <span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;">Image1.value.image.value </span><span style="color: blue; font-size: x-small;"><span style="color: blue; font-size: x-small;">=</span></span><span style="font-size: x-small;"> TextField1.desc.Image.value;</span></span><br />
<br />
Form variables created using Form Properties … Variables are stored under a <variables> element, when created by LiveCycle Designer they are always text, but it is valid for them to be any of the types that can be used under the <span style="font-family: "Courier New", Courier, monospace;"><desc></span> element. This allows references to the variables in JavaScript to be typed, so by editing the XML Source can make your JavaScript code simpler, at least when dealing with Number and Boolean form variables. Once you have made this change Designer will show them as a “?” icon in the hierarchy palette (see image below) but this has never caused any problem in my forms.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-biWJsDW2My8/VN7YqHr_78I/AAAAAAAAAOs/HgivitRAjMg/s1600/IntegerFormVariable.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-biWJsDW2My8/VN7YqHr_78I/AAAAAAAAAOs/HgivitRAjMg/s1600/IntegerFormVariable.png" /></a></div>
And looks like this in the XML Source window.<br />
<br />
<span lang="EN-AU"><span style="font-size: x-small;">
</span></span><br />
<span style="font-size: x-small;"> <span style="font-family: "Courier New", Courier, monospace;"><</span></span><span style="font-family: "Courier New", Courier, monospace;"><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">variables</span></span><span style="font-size: x-small;">></span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">
</span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"> <</span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">text</span></span><span style="font-size: x-small;"> </span><span style="color: #0080ff; font-size: x-small;"><span style="color: #0080ff; font-size: x-small;">name</span></span><span style="font-size: x-small;">="</span><span style="color: teal; font-size: x-small;"><span style="color: teal; font-size: x-small;">Text</span></span><span style="font-size: x-small;">"/></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"> <</span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">integer</span></span><span style="font-size: x-small;"> </span><span style="color: #0080ff; font-size: x-small;"><span style="color: #0080ff; font-size: x-small;">name</span></span><span style="font-size: x-small;">="</span><span style="color: teal; font-size: x-small;"><span style="color: teal; font-size: x-small;">Integer</span></span><span style="font-size: x-small;">"/></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"> </</span><span style="color: red; font-size: x-small;"><span style="color: red; font-size: x-small;">variables</span></span><span style="font-size: x-small;">></span></span><br />
<span style="font-family: inherit; font-size: x-small;"><br /><br />
<br /> </span>BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-88297476216183048812015-01-28T02:16:00.001-08:002015-02-20T23:42:15.083-08:00Adobe LiveCycle Designer Tip #7 - Formatting TooltipsWith the tooltips available with LiveCycle Designer there is no options to add formatting to a tooltip. You can try using a subform and dynamically position it next to the field, like this sample <a href="http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2014/06/season-planner-or-year-planner-pdf.html" target="_blank">Season Planner (or Year Planner) PDF Template.</a><br />
<br />
One thing you can do is add some carriage returns to add some vertical space. For a long time I was doing this by editing the XML Source and adding a carriage return character "&#xD;" in the <span style="color: red; font-family: "Courier New", Courier, monospace; font-size: x-small;">toolTip</span> value.<br />
<br />
But you can do the same thing from the Accessibility palette by using a ctrl-Enter key combination. <br />
<br />
Seems everywhere you can enter a rich text value you can use shift-Enter but maybe because the Tool Tip value in the Accessibility palette is not rich text we have to use ctrl-Enter.<br />
<br />
You can also gain some control over the tooltip width by using a non-breaking space (Ctrl-Shift-Space, which inserts a 0xc2a0 character) instead of a normal space.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com4tag:blogger.com,1999:blog-7970679050025899967.post-58453367037873845882015-01-10T21:05:00.001-08:002020-12-30T20:52:11.565-08:00Custom Bulleted and Numbered ListsWith LiveCycle Designer ES3 came support for bulleted and numbered lists under the Paragraph palette. This did make creating lists a lot easier but also added some restrictions;<br />
<ul>
<li>There is always a 0.5in margin added to the list, see <a href="http://partners.adobe.com/public/developer/en/xml/xfa_spec_3_3.pdf#nameddest=G34.1363978" target="_blank">List Layout (XFA Spec 3.3)</a> for more details</li>
</ul>
What ES3 gives you is <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-twmRVUjSCPs/VLH-YaiI-lI/AAAAAAAAAN8/u4Johmwh60g/s1600/ES3.Bullets.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-twmRVUjSCPs/VLH-YaiI-lI/AAAAAAAAAN8/u4Johmwh60g/s1600/ES3.Bullets.PNG" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
What you might have been after<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-UkMrmur-HD8/VLH-YPFTE6I/AAAAAAAAAN4/p2wPFK3UqqY/s1600/Custom.Bullets.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-UkMrmur-HD8/VLH-YPFTE6I/AAAAAAAAAN4/p2wPFK3UqqY/s1600/Custom.Bullets.PNG" /></a></div>
<ul>
<li>There is no option to add a leader (dots between the bullet/number and the text)</li>
</ul>
Now you number list can look like<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-XOPvyENLYZ0/VLH_5qSGZfI/AAAAAAAAAOM/W4OAnA1AH-Q/s1600/Custom.Leaders.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-XOPvyENLYZ0/VLH_5qSGZfI/AAAAAAAAAOM/W4OAnA1AH-Q/s1600/Custom.Leaders.PNG" /></a></div>
<ul>
<li>When read by a screen reader like NVDA the bullet characters or numbers are not announced. In the example in the first dot point above, NVDA announces "What is your favourite fruit Apples Oranges Bananas" when what you probably wanted was "What is your favourite fruit <em>bullet</em> Apples <em>bullet</em> Oranges <em>bullet</em> Bananas"</li>
</ul>
In LiveCycle Designer the Text fields containing rich text that we need to use to implement a bullet list are implemented using a subset of xHTML. ES3 introduced support for the ol, ul and li tags but prior to ES3 it was also possible to create bullet point lists and numbered list you just had to hand edit the xHTML, and use a negative <strong>text-indent</strong> and some <strong>tab-stops</strong>.<br />
<br />
This sample PDF Form makes to easy, just enter the text of your dot points, select the type of bullets or numbers, the spacing and if you want leaders or not and the Draw element (which implements the Text object) is output to the console.<br />
<br />
You should see something like;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><draw name="Text1" w="196.85mm" minH="0in" xmlns="http://www.xfa.org/schema/xfa-template/3.6/"><br /> <value><br /> <exData contentType="text/html"><br /> <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p style="text-indent:-10mm;xfa-tab-stops:left leader (dots page 3pt) 10mm"><span style="font-size:9pt">1.</span><span style="xfa-tab-count:1"/><span style="font-size:9pt">Oranges</span></p><p style="text-indent:-10mm;xfa-tab-stops:left leader (dots page 3pt) 10mm"><span style="font-size:9pt">2.</span><span style="xfa-tab-count:1"/><span style="font-size:9pt">Apples</span></p><p style="text-indent:-10mm;xfa-tab-stops:left leader (dots page 3pt) 10mm"><span style="font-size:9pt">3.</span><span style="xfa-tab-count:1"/><span style="font-size:9pt">Bananas</span></p></body><br /> </exData><br /> </value><br /> <ui><br /> <textEdit allowRichText="1"/><br /> </ui><br /> <font typeface="Myriad Pro"/><br /></draw></span><br />
<br />
To add this to your form it might be easiest to add a Text object in the place you need, select it, then switch to the XML Source view. You should see a <draw>...</draw> element, which you can replace with the one copy and pasted from the JavaScript console.<br />
<br />
The sample to generate the Draw element is <a href="https://drive.google.com/file/d/1s8xicB1RkXrIlU3W5Dy_5RFMa2n-1hnc/view?usp=sharing">Bullets.pdf.</a><br />
<br />
A form containing samples of ES3 and customs bullet/number lists and how NVDA reads them is <a href="https://drive.google.com/file/d/1cwKvrfUh5x58uzgC9k4FVgJJsYgbzTlp/view?usp=sharing">NVDA.Bullets.pdf</a>.<br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-46810110644482552782014-09-26T16:35:00.001-07:002020-12-30T20:53:06.788-08:00Listing all fields in a form - The macro - Part TwoI have added some new columns to the Designer ES macro that creates a list of all the XFA objects within a form.<br />
<br />
The new columns are;<br />
<ul>
<li>somExpression</li>
<li>presence</li>
<li>field type (rich text or plain text)</li>
<li>the maximum length of the text field</li>
</ul>
The new macro can be downloaded here, <a href="https://drive.google.com/file/d/1cwKvrfUh5x58uzgC9k4FVgJJsYgbzTlp/view?usp=sharing">XFAObjectLister.zip.</a><br />
<br />
More details here, <a href="http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2014/02/listing-all-fields-in-form-macro.html">Listing all fields in a form - The macro</a>.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-67542279839285774982014-09-15T05:13:00.000-07:002014-09-15T15:01:24.638-07:00Adobe LiveCycle Designer Tip #6 - Subform IndicatorsOne of the new features of Designer ES2 was Subform Indicators. These are the green subform icons that appeared on the Design view. Also as part of ES2 there was new option under the View menu to turn them off, which I did straight away as I didn’t see the use of them.<br>
<br>So if you are like me and did not realised that you can click on them to select the subform, you might what to give them another go. They are particularly useful when you have many subforms sharing a top edge.<br>
<br>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-3T-sgdWS31E/VBbXXuaBMDI/AAAAAAAAANU/4snvYhkStfk/s1600/Subform%2BIndicators.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-3T-sgdWS31E/VBbXXuaBMDI/AAAAAAAAANU/4snvYhkStfk/s1600/Subform%2BIndicators.png" height="216" width="400"></a></div>
<br>
Now all we need is an indicator to allow us to select an exclGroup<br>
<br>
<br>
<br>BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-77150913670151468772014-08-27T15:11:00.004-07:002020-12-30T20:58:40.711-08:00Calling a RESTful web service from a PDF form.<span style="font-family: Arial, sans-serif;">You can retrieve results of a RESTful web service by sending an HTTP GET request to the URL. Within a PDF form we can use the FormCalc Get function to send an HTTP GET request. If the service returns XML then we can load the results into a data connection and bind our form elements to it and the results will appear on the PDF form.</span><br />
<span style="font-family: Arial, sans-serif;"><br /></span>
<span style="font-family: Arial, sans-serif;">In this sample I am using the Google Customs Search service, this allows you to specify a list of URLs and search within that subset. To be almost useful and related to this blog topic I have included the websites I have found useful when looking for information related to PDF XML forms.</span><br />
<span style="font-family: Arial, sans-serif;"><br /></span>
<span style="font-family: Arial, sans-serif;">To get an idea what the form is doing paste the following URL (which will perform a search for the word loadXML) into your browser address field, then do a "View Source" on the results to see what this sample form has to deal with.</span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><a href="https://www.googleapis.com/customsearch/v1?key=AIzaSyCESW0ptt79sXXv9Cdz7lLDocNIBTJWH48&cx=015851576802315024878:qkoprvhbpgc&q=image&alt=atom">https://www.googleapis.com/customsearch/v1?key=AIzaSyCESW0ptt79sXXv9Cdz7lLDocNIBTJWH48&cx=015851576802315024878:qkoprvhbpgc&q=image&alt=atom</a></span><br />
<br />
<span style="font-family: Arial, sans-serif;">The important parts of the URL is, <span style="font-size: x-small;">q=image</span>, the actual search term and <span style="font-size: x-small;">alt=atom</span>, which means the results will be in an atom (XML) feed format (the default is a JSON format). The other bits are to identify the custom search to use.</span><br />
<span style="font-family: Arial;"></span><br />
<span style="font-family: Arial;">The response will be en entry element for each Google search result returned, something like;</span><br />
<span style="font-family: Arial;"></span><br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"> <<span style="color: red;">entry</span> <span style="color: blue;">gd:kind</span>="<span style="color: #38761d;">customsearch#result</span>"><br /> <<span style="color: red;">id></span>http://adobelivecycledesignercookbookbybr001.blogspot.com/2014/03/using-utilprint-methods.html</<span style="color: red;">id</span>><br /> <<span style="color: red;">updated</span>>1970-01-17T07:20:53.790Z</<span style="color: red;">updated</span>><br /> <<span style="color: red;">title</span> <span style="color: blue;">type</span>="<span style="color: #38761d;">html</span>">Adobe LiveCycle Designer Cookbooks by BR001: Using the &lt;b&gt;util&lt;/b&gt; &lt;b&gt;...&lt;/b&gt;</<span style="color: red;">title</span>><br /> <<span style="color: red;">link</span> <span style="color: blue;">href</span>="</span><a href="http://adobelivecycledesignercookbookbybr001.blogspot.com/2014/03/using-utilprint-methods.html"><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">http://adobelivecycledesignercookbookbybr001.blogspot.com/2014/03/using-utilprint-methods.html</span></a><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">" <span style="color: blue;">title</span>="<span style="color: #38761d;">adobelivecycledesignercookbookbybr001.blogspot.com</span>"/><br /> <<span style="color: red;">summary</span> <span style="color: blue;">type</span>="<span style="color: #38761d;">html</span>">Mar 27, 2014 &lt;b&gt;...&lt;/b&gt; var v = util.printx(&amp;quot;9999999999&amp;quot;,&amp;quot;My phone number is (02) 1111 2222&amp;quot;) ... var v = &lt;br&gt;<br />&lt;b&gt;util&lt;/b&gt;.&lt;b&gt;printf&lt;/b&gt;(&amp;quot;%,105d&amp;quot;, 2)console.println(v), 00002, Prints the&amp;nbsp;...</<span style="color: red;">summary</span>><br /> <<span style="color: red;">cse:cacheId</span>>NwQJCo32ZJcJ</<span style="color: red;">cse:cacheId</span>><br /> <<span style="color: red;">cse:formattedUrl</span> <span style="color: blue;">type</span>="<span style="color: #38761d;">html</span>">adobelivecycledesignercookbookbybr001.blogspot.com/.../using-&lt;b&gt;util&lt;/b&gt;print- methods.html</<span style="color: red;">cse:formattedUrl</span>><br /> <<span style="color: red;">cse:PageMap</span>><br /> <<span style="color: red;">cse:DataObject</span> <span style="color: blue;">type</span>="<span style="color: #38761d;">metatags</span>"><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">viewport</span>" <span style="color: blue;">value</span>="<span style="color: #38761d;">width=1100</span>"/><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">author</span>" <span style="color: blue;">value</span>="<span style="color: #38761d;">Bruce</span>"/><br /> </<span style="color: red;">cse:DataObject</span>><br /> <<span style="color: red;">cse:DataObject</span> <span style="color: blue;">type</span>="<span style="color: #38761d;">blogposting</span>"><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">blogid</span>" <span style="color: blue;">value</span>="7970679050025899967"/><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">postid</span>" <span style="color: blue;">value</span>="5034164472928527349"/><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">name</span>" <span style="color: blue;">value</span>="<span style="color: #38761d;">Using the util.print methods</span>"/><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">description</span>" <span style="color: blue;">value</span>="Generally we can you display patterns to for formatting but there are times when we have to format values in code, and there are three handy methods in the Adobe Reader API; util.printd()for..."/><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">articlebody</span>" <span style="color: blue;">value</span>="Generally we can you display patterns to for formatting but there are times when we have to format values in code, and there are three handy methods in the Adobe Reader API; util.printd()for..."/><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">url</span>" value="</span><a href="http://adobelivecycledesignercookbookbybr001.blogspot.com/2014/03/using-utilprint-methods.html%22/"><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">http://adobelivecycledesignercookbookbybr001.blogspot.com/2014/03/using-utilprint-methods.html"/</span></a><span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">><br /> <<span style="color: red;">cse:Attribute</span> <span style="color: blue;">name</span>="<span style="color: #38761d;">datepublished</span>" <span style="color: blue;">value</span>="<span style="color: #38761d;">Thursday, March 27, 2014</span>"/><br /> </<span style="color: red;">cse:DataObject</span>><br /> </<span style="color: red;">cse:PageMap</span>><br /> </<span style="color: red;">entry</span>></span><br />
<span style="font-family: Arial, sans-serif;"><br /></span>
</div>
<span style="font-family: Arial, sans-serif;">You can play with the search using the public URL, </span><a href="https://www.google.com.au/cse/publicurl?cx=015851576802315024878:qkoprvhbpgc"><span style="font-family: Arial, sans-serif;">https://www.google.com.au/cse/publicurl?cx=015851576802315024878:qkoprvhbpgc</span></a><span style="font-family: Arial, sans-serif;">, </span><br />
<span style="font-family: Arial, sans-serif;"></span><br />
<span style="font-family: Arial, sans-serif;"><strong><em>NOTE: this is a free service so only 100 searches can be made a day, if you find this useful then you should setup your own custom search and change the key and cx values, in the sample PDF form these values are defined as Form Variables). </em></strong></span><br />
<span style="font-family: Arial, sans-serif;"><br /></span>
<span style="font-family: Arial, sans-serif;">The results of this search will appear in the sample form like;</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-0JNhLkZ68ak/U_z1YgWebMI/AAAAAAAAAMw/9Bji9s-33wo/s1600/GoogleSearch.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-0JNhLkZ68ak/U_z1YgWebMI/AAAAAAAAAMw/9Bji9s-33wo/s1600/GoogleSearch.JPG" height="400" width="391" /></a></div>
<br />
<h4>
<span style="font-family: Arial, sans-serif;">Security</span></h4>
<span style="font-family: Arial, sans-serif;">The user experience will differ depending on the version of Reader (or Acrobat) being used and if you are using Reader standalone or the browser plugin. With the standalone Reader expect to see a popup message like;</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-2-Y1Uf_65Wk/U_1T05gzx3I/AAAAAAAAANA/7NQUhhGQ-x0/s1600/This%2Bdocument%2Bis%2Btrying%2Bto%2Bconnect%2Bto.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" closure_lm_291658="null" cua="true" src="http://1.bp.blogspot.com/-2-Y1Uf_65Wk/U_1T05gzx3I/AAAAAAAAANA/7NQUhhGQ-x0/s1600/This%2Bdocument%2Bis%2Btrying%2Bto%2Bconnect%2Bto.PNG" height="143" width="320" /></a></div>
<span style="font-family: Arial, sans-serif;"></span><br />
<span style="font-family: Arial, sans-serif;">Selecting allow with "Remember this action ..." selected will add the site to "Always Allow" list under Edit ... Preferences ... Trust Manager ... "Internet Access from PDF Files outside the web browser" ... Change Settings. This dialog has options to always allow or always block, and the option to remove googleapis.com once you have finished playing with this sample.</span><br />
<br />
<h4>
<span style="font-family: Arial, sans-serif;">Retaining state during a xfa.form.remerge(); </span></h4>
<span style="font-family: Arial, sans-serif;">When we click the Search (or More) button the atom feed is loaded into the default data connection and an xfa.form.remerge() is called to bind up the results. Calling remerge means all properties that are not bound to the data connection revert to their original values. So if a form object starts off being invisible and we make if visible at some point then calling remerge reverts it to invisible. </span><br />
<br />
<span style="font-family: Arial, sans-serif;">A way of retaining the form state is to set up a separate dataset and bind to that. I have done this by typing the definition into the XML Source view. So this form has the following data structure;</span><br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;"><<span style="color: red;">xfa:datasets</span> <span style="color: blue;">xmlns:xfa</span>="</span><a href="http://www.xfa.org/schema/xfa-data/1.0/"><span style="color: #38761d; font-family: "Courier New", Courier, monospace; font-size: xx-small;">http://www.xfa.org/schema/xfa-data/1.0/</span></a><span style="font-size: xx-small;"><span style="font-family: "Courier New", Courier, monospace;">"><br /> <<span style="color: red;">xfa:data</span> <span style="color: blue;">xfa:dataNode</span>="<span style="color: #38761d;">dataGroup</span>"/><br /> <<span style="color: red;">FormState</span>><br /> <<span style="color: red;">SearchTerms</span>/><br /> <<span style="color: red;">Feed</span>/><br /> <<span style="color: red;">AllinUrl</span>><br /> <<span style="color: red;">Value</span>>0</<span style="color: red;">Value</span>><br /> </<span style="color: red;">AllinUrl</span>><br /> <<span style="color: red;">IncludeDuplicates</span>><br /> <<span style="color: red;">Value</span>>0</<span style="color: red;">Value</span>><span style="color: purple;"><!-- 0 for not included, otherwise 1 --></span><br /> <<span style="color: red;">Count</span>>0</<span style="color: red;">Count</span>><br /> <<span style="color: red;">Presence</span>>hidden</<span style="color: red;">Presence</span>><br /> </<span style="color: red;">IncludeDuplicates</span>><br /> <<span style="color: red;">Results</span>><br /> <<span style="color: red;">Presence</span>>hidden</<span style="color: red;">Presence</span>><br /> </<span style="color: red;">Results</span>><br /> <<span style="color: red;">DidYouMean</span>><br /> <<span style="color: red;">Presence</span>>hidden</<span style="color: red;">Presence</span>><br /> <<span style="color: red;">Text</span>/><br /> <<span style="color: red;">ToolTip</span>/><br /> </<span style="color: red;">DidYouMean</span>><br /> <<span style="color: red;">MoreButton</span>><br /> <<span style="color: red;">Presence</span>>hidden</<span style="color: red;">Presence</span>><br /> <<span style="color: red;">StartIndex</span>>0</<span style="color: red;">StartIndex</span>><br /> </<span style="color: red;">MoreButton</span>><br /> </<span style="color: red;">FormState</span>><br /><<span style="color: red;">dd:dataDescription</span> <span style="color: blue;">xmlns:dd</span>="</span><span style="color: #38761d; font-family: "Courier New", Courier, monospace;">http://ns.adobe.com/data-description/</span><span style="font-family: "Courier New", Courier, monospace;">" <span style="color: blue;">dd:name</span>="<span style="color: #38761d;">feed</span>"></span></span><br />
<span style="font-size: x-small;"></span><br /></div>
<br />
<span style="font-size: x-small;"><span style="font-family: Arial, sans-serif; font-size: small;">Now in the code we can reference these values using an somExpression like; </span></span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">xfa.datasets.FormState.Feed.value</span><br />
<span style="font-size: x-small;"><span style="font-family: Arial, sans-serif; font-size: small;"><br /><span style="font-family: Arial, sans-serif;">We can also use the setProperty element to bind directly to the property, so the DidYouMean subform XML Source looks like;</span><br />
<br />
</span></span><br />
<div style="line-height: 1;">
<span style="font-size: x-small;"><span style="font-family: Arial, sans-serif; font-size: small;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><<span style="color: red;"><span style="color: red;">subform</span></span> <span style="color: #0080ff;"><span style="color: #0080ff;">w</span></span>="<span style="color: #38761d;">199mm</span>" <span style="color: #0080ff;"><span style="color: #0080ff;">name</span></span>="<span style="color: #38761d;">DidYouMean</span>"></span></span></span></div>
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> <<span style="color: red;"><span style="color: red;">setProperty</span></span> <span style="color: #0080ff;"><span style="color: #0080ff;">target</span></span>="<span style="color: #38761d;">presence</span>" <span style="color: #0080ff;"><span style="color: #0080ff;">ref</span></span>="<span style="color: #38761d;">!FormState.DidYouMean.Presence</span>"/></span><br />
<span style="font-family: Arial, sans-serif;"></span><br />
<span style="font-family: Arial, sans-serif;">This means if a spelling correction comes back from the Google search we can set the value in our FormState dataset to visible, call remerge, and the subform will appear.</span><br />
<br />
<h4>
Default Button</h4>
<span style="font-size: x-small;"><span style="font-family: Arial, sans-serif; font-size: small;"><span style="font-family: Arial, sans-serif;">All the other form technologies I have used have allowed you to specify a default action when the enter key is pressed during form filling. This wouldn’t work for multi-lined text fields and that maybe why a default was not implemented. But in a simple form like this it can be useful, and is easy to implement now we have event propagation. Pressing the enter key will cause the exit event to fire, with a commitKey value of 2. So if we add the following code to the exit event of the Search Term field we can start the search when the enter key is pressed.</span>
</span></span><br />
<div style="line-height: 1;">
<span style="font-size: x-small;"><span style="font-family: Arial, sans-serif; font-size: small;"><span style="font-family: Arial, sans-serif;"></span></span></span><br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;">if</span> (xfa.event.commitKey <span style="color: blue;">===</span> <span style="color: #ff9900;">2</span>)<o:p></o:p></span></span>
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">
{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> Button.Search.execEvent(<span style="color: #ff9900;">"click"</span>);</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">
</span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">}</span></div>
<br />
<h4>
Binary Result Data</h4>
<span style="font-family: Arial, Helvetica, sans-serif;">You might want to try and return a binary response, such as the .PNG data of an image, but this does not appear to work. If you get any response at all it is only the first few characters.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">To update pictures in a form you will probably have to base64 encode them on the server first.</span><br />
<span style="font-family: Arial;"></span><br />
<h4>
Sample</h4>
The sample XDP template, fragments, images and schema files can be downloaded in the zip file <a href="https://drive.google.com/uc?export=download&id=1SCB9fnIHO3IBPHI9jOvFYSo6yT-BUpwW">GoogleSearch.zip</a>. You don't necessarily need to define a XML Schema, but in this case it helped me understand what the response will look like.<br />
<br />
If you just want to play with the sample download <a href="https://drive.google.com/uc?export=download&id=1HF-EsrWZBwKeL5GK9PPAgdxfvK2BPgWs">GoogleSearch.pdf</a>.<br />
<br />
<span style="font-family: Arial;"></span><br />
<span style="font-family: Arial;"></span><br />
<span style="font-family: Arial;"></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"></span><br />
<span style="font-size: xx-small;"></span><br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com2tag:blogger.com,1999:blog-7970679050025899967.post-64413620900248787072014-07-11T00:00:00.002-07:002020-12-30T21:02:56.890-08:00Yet another way of looping though a list of form nodes<span style="font-family: Arial, Helvetica, sans-serif;">SpiderMonkey JavaScript 1.7 (the JavaScript engine used in Firefox and Adobe Reader) introduced an Iterator extension. This is not available in other browsers but we don't need to worry about that. With a custom Iterator we can loop though form nodes using for ... in statement; </span><br />
<br />
<div style="line-height: 1;">
<span style="color: blue; font-family: Courier New; font-size: xx-small;">for</span><span style="font-family: Courier New; font-size: xx-small;"> (</span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">var</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> field </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">in</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> XFAUtil.NodeIterator(NumericField))</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;">{</span><br />
<span style="font-family: Courier New; font-size: xx-small;">
</span><span style="font-family: Courier New; font-size: xx-small;"> console.println(field.somExpression </span><span style="color: blue; font-family: Courier New; font-size: xx-small;">+</span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">" has a value of "</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">+</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> field.rawValue);</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
}</span></span></div>
<br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><span style="font-family: Myriad Pro;"></span>
<span style="font-family: Myriad Pro;">An iterator is used by assigning a generator function to the __iterator__ method, so the NodeIterator object used above looks like;</span><br />
<div style="line-height: 1;">
<span style="font-family: Myriad Pro; font-size: x-small;"><span style="font-family: Myriad Pro; font-size: x-small;">
</span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"></span></span></span>
<span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"></span></span></span><br />
<span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">function</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> NodeIterator(node)</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
{<br />
</span></span><span style="font-family: Courier New; font-size: xx-small;"> </span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"> var</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> nodeList </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> node.parent.resolveNodes(node.name </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">+</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">"[*]"</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">);</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;">
</span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"> var</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> limit </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> nodeList.length;</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;">
</span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"> var</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> current </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">0</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">;</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;">
</span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"> return</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> {</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;">
</span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> __iterator__ </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">:</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">function</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> ()</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
{<br />
</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"> return</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> {</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> next </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">:</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">function</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> ()</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;">
{<br />
</span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"> if</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> (current </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">>=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> limit) </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">throw</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> StopIteration;</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"> return</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> nodeList.item(current</span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">++</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">);</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
}<br />
}<br />
}<br />
}<br />
}</span></span></div>
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Myriad Pro; font-size: x-small;"><span style="font-size: small;"></span><br /></span></span></span>
<span style="font-family: Myriad Pro; font-size: x-small;"><span style="font-size: small;">The problem with this is the StopIteration exception gets thrown when we get to the end of the list. This probably won't be a problem for the end user but is a pain for the developers who will typically have the "When exception thrown" option set to break. </span><br />
</span><br />
<span style="font-family: Myriad Pro; font-size: x-small;"><span style="font-size: small;">We can hide this by adding a forEach method similar to the one available for an array. For example to sum the values of an array we can do;</span></span><br />
<br />
<div style="line-height: 1;">
<span style="color: blue; font-family: Courier New; font-size: xx-small;">var</span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> total </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">0</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">;</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">[</span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">1</span></span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">,</span></span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">2</span></span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">,</span></span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">3</span></span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">,</span></span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">4</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">].forEach(</span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">function</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">(v) { total </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">+=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> v; });</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">console.println(total); </span></span><span style="color: green; font-family: Courier New; font-size: xx-small;"><span style="color: green; font-family: Courier New; font-size: xx-small;"><span style="color: green; font-family: Courier New; font-size: xx-small;">// prints 10 </span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Similarly we can now sum up all the values of all the numeric fields called NumericField using;</span><br />
<span style="font-family: Arial;"></span><br />
<div style="line-height: 1;">
<span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">var</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> total </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">0</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">;</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">XFAUtil.NodeIterator(NumericField).forEach(</span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">function</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">(v) { total </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">+=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> v.rawValue; });</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">total;</span></span><br />
<span style="font-family: Arial;"></span><br /></div>
<br />
<span style="font-family: Arial, Helvetica, sans-serif;">Or</span> process all the fields of the same type using the NodeClassIterator<br />
<br />
<div style="line-height: 1;">
<span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">var</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> total </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">0</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">;</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">XFAUtil.NodeClassIterator(CheckBox1).forEach(</span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">function</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">(v) { </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">if</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> (v.rawValue </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">===</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">1</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">) total</span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">++</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">; });</span></span><br />
<span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">
</span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">MessageText.presence </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> (total </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">>=</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">2</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;">) </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">?</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">"hidden"</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;"><span style="color: blue; font-family: Courier New; font-size: xx-small;">:</span></span></span><span style="font-family: Courier New; font-size: xx-small;"><span style="font-family: Courier New; font-size: xx-small;"> </span></span><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;"><span style="color: #ff6600; font-family: Courier New; font-size: xx-small;">"visible"</span></span></span></div>
<br />
It may still be better to use the good old for loop, the main advantage of using this technic is it hide some of the XFA stuff. But maybe if you have some rule regarding all rows with a a quantity value greater than 100 then it would be good to put this logic in the one place.<br />
<br />
Here's a sample form using the approach, <a href="https://drive.google.com/uc?export=download&id=1P_kGsW3RzaN6AdUmkEJtvBJPkgPcGzGA">CustomIterator.pdf</a>.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-21665921097018454372014-07-03T00:00:00.000-07:002014-07-03T00:00:04.071-07:00Adobe LiveCycle Designer Tip #5 - Palette ControlDesigner has 16 different palettes, a design surface and a script editor window. In an ideal world we would have two screens so we can spread them all out.<br />
<br />
For those of us with only one screen moving from palette to palette can be a pain. If you have them docked at the sides then you'll need to click the 'thumb' controls to expand, which I find a bit of a small target to click on.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-nXY1rL-Z2mU/U7FMr8C0JHI/AAAAAAAAAMM/tV-T_6gntp0/s1600/ThumbControls.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-nXY1rL-Z2mU/U7FMr8C0JHI/AAAAAAAAAMM/tV-T_6gntp0/s1600/ThumbControls.png" /></a></div>
<br />
What I find easier is to have the palettes in one palette window. I have the Hierarchy, Data View, Style Catalog, Info, Font, Paragraph, Drawing Aids, Style Catalog on the left and Object, Layout, Border, Accessibility, Object Library, Fragment Library on the right.<br />
<br />
To drag a palette onto another palette window drag the palette tab (not the palette title bar) on top of the target palette.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-e9fCl2LI-KE/U7FNwciYNUI/AAAAAAAAAMU/AwwMW9mTus4/s1600/PaletteTab.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-e9fCl2LI-KE/U7FNwciYNUI/AAAAAAAAAMU/AwwMW9mTus4/s1600/PaletteTab.png" /></a></div>
<br />
You can then end up with a layout looking like;<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-WfizcJsX24I/U7FOIPdNuEI/AAAAAAAAAMc/fTh4Od5Cs80/s1600/PaletteLayout.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-WfizcJsX24I/U7FOIPdNuEI/AAAAAAAAAMc/fTh4Od5Cs80/s1600/PaletteLayout.png" height="67" width="640" /></a></div>
<br />
<br />
Which gives me a bigger target to click on.<br />
BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-88661871284246113692014-06-24T05:44:00.001-07:002020-12-30T21:04:29.412-08:00Season Planner (or Year Planner) PDF TemplateThis is a sample PDF form that generates a calendar with each month on a separater row and with all the weekends lined up in the same columns.<br />
<br />
You can select a paper size, language, a start and end date and the colors and patterns for the borders, weekends, unused cells. Once the calendar has been generated you can then enter the details of the events in the calendar. Use ctrl-e to bring up the format text toolbar, you can also use ctrl-click to bring up a menu of color and fill pattern options.<br />
<br />
The final PDF can then end up with something that looks like this;<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-WpDQ5p5HekI/U6ZJMdQy5dI/AAAAAAAAALM/yQRR20OZQTo/s1600/SeasonCalendar.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-WpDQ5p5HekI/U6ZJMdQy5dI/AAAAAAAAALM/yQRR20OZQTo/s1600/SeasonCalendar.PNG" height="280" width="400" /></a></div>
<br />
On the screen, at normal magnification, the borders may appear to be overwritten but on paper the come out fine.<br />
<br />
If you have stumbled across this page looking for something to generate a calendar then you can down load the <a href="https://drive.google.com/uc?export=download&id=1WQh83lw8NGTWH_hQmhBwrf1XbmCtzBbt">SeasonCalendar.pdf</a>, fill in the fields and away you go. If you are using Adobe Reader you may get a message saying "Cannot save file information", in which case you can try printing to a file or if all you are after is a paper copy then the standard printing options will still work.<br />
<br />
This blog is about working with PDF Forms (or Adobe XML Forms ... XFA), so only continue reading if you want some ideas about writing your own forms.<br />
<br />
<h3>
Tool Tips</h3>
The tool tips in this form are generated by positioning a subform next to the relevant field instead of using the built in tooltips. This allows for rich text to be used and a more attractive looking tooltip. The fields can still be in a flowed container as long as the parent container is positioned and the tooltip subforms are in the same positioned container.<br />
<br />
This sample uses two subforms, one with a arrow pointing up to be positioned under a field and one with an arrow point left to be positioned to the right of a field.<br />
<br />
Each field defines it's tooltip text in the initialise event;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> helpText <span style="color: blue;">=</span> <span style="color: blue;"><</span>body xmlns<span style="color: blue;">=</span><span style="color: orange;">"http://www.w3.org/1999/xhtml</span></span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: orange;">"</span> xmlns:xfa<span style="color: blue;">=</span><span style="background-color: white; color: orange;">"http://www.xfa.org/schema/xfa-data/1.0/</span></span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="background-color: white; color: orange;">"</span><span style="color: blue;">></span><br /><span style="color: blue;"><</span>p<span style="color: blue;">></span>Select to render each day before the next, otherwise the calendar will be laid out and rendered when finished, which is probably quicker but will appear like nothing is happening for sometime.<span style="color: blue;"></</span>p<span style="color: blue;">></span><br /><span style="color: blue;"></</span>body<span style="color: blue;">></span>;<br />item <span style="color: blue;">=</span> xfa.form.createNode(<span style="color: orange;">"exData"</span><span style="color: blue;">,</span> <span style="color: orange;">"helpText"</span>);<br />this.desc.nodes.append(item);<br />item.value <span style="color: blue;">=</span> helpText.toXMLString();</span><br />
<br />
The position of the tooltip subform will default to a generally acceptable position but can be adjusted with the following also in the initialise event;<br />
<br />
<span style="color: blue;">var</span> xOffset <span style="color: blue;">=</span> xfa.form.createNode(<span style="color: orange;">"integer"</span><span style="color: blue;">,</span> <span style="color: orange;">"xOffset"</span>);<br />
this.desc.nodes.append(xOffset);<br />
xOffset.value <span style="color: blue;">=</span> <span style="color: orange;">48</span>;<br />
<br />
The effect you end up with looks like this;<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-dMfWNNlwVME/U6ZbHQlUwqI/AAAAAAAAALc/ZGV-sJI3p6k/s1600/SeasonCalendar2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-dMfWNNlwVME/U6ZbHQlUwqI/AAAAAAAAALc/ZGV-sJI3p6k/s1600/SeasonCalendar2.gif" height="320" width="320" /></a></div>
<br />
These tooltips can also be used to display error messages as you can see for the start date field.<br />
<h3>
Incremental Rendering</h3>
This sample also shows several examples of updating the form contents as the form is being laided out. Generally with a PDF form all the form objects are laided out and then rendered at the end. This sample uses the layout:ready event to draw the next form object, which then triggers another layout:ready event to fire and the next form object to be drawn. A form variable is used to keep track of what the next form object should be.<br />
<br />
The first example is updating a 'console log' on the first page with calculation results, line at a time. In this case the updating the form text field value does not cause the layout:ready event to fire so we have to manually trigger it with the <span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">xfa.layout.relayout()</span> method ourselves. <br />
<br />
The second example places some instruction text overtop of the calendar but gradually fades out before the calendar is completed.<br />
<br />
The third example is drawing the actuals cells of the calendar. This particular example means that the total time taken to draw the calendar is longer but at least now we can see something happening. It also mains the return button can be clicked while the form is still rendering.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-J8aAkOSkfvs/U6grrunRlwI/AAAAAAAAAL8/vRJVQ4_UeYc/s1600/SeasonCalendar3.trimmed.cropped.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-J8aAkOSkfvs/U6grrunRlwI/AAAAAAAAAL8/vRJVQ4_UeYc/s1600/SeasonCalendar3.trimmed.cropped.gif" height="60" width="320" /></a></div>
<br />
<h3>
Selecting Page Size</h3>
Another option in this sample is the ability to select the page size. The easiest way to do this is to duplicate all the form objects for each page size. But in this example all the form objects are defined under the (Reference Objects) node in the hierarchy view. We then have a page for each page size in the form with an initial occurrence count of zero and the one that has been selected. Looking in the XML view you can see that each page just has a reference to the calendar objects;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"><</span><span style="color: #a31515;">subform</span><span style="color: blue;"> </span><span style="color: red;">w</span><span style="color: blue;">=</span>"<span style="color: blue;">197.3mm</span>"<span style="color: blue;"> </span><span style="color: red;">h</span><span style="color: blue;">=</span>"<span style="color: blue;">284.3mm</span>"<span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">A4Portrait</span>"<span style="color: blue;">></span></span></span><br />
<span style="color: blue;"></span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> </span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"><</span><span style="color: #a31515;">breakBefore</span><span style="color: blue;"> </span><span style="color: red;">targetType</span><span style="color: blue;">=</span>"<span style="color: blue;">contentArea</span>"<span style="color: blue;"> </span><span style="color: red;">target</span><span style="color: blue;">=</span>"<span style="color: blue;">A4Portrait.A4PortraitContentArea</span>"<span style="color: blue;">/></span>
</span></span><br />
<span style="color: blue;"></span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">
</span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"><</span><span style="color: #a31515;">bind</span><span style="color: blue;"> </span><span style="color: red;">match</span><span style="color: blue;">=</span>"<span style="color: blue;">none</span>"<span style="color: blue;">/></span> </span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"></span></span></span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> <</span><span style="color: #a31515;">event</span><span style="color: blue;"> </span><span style="color: red;">activity</span><span style="color: blue;">=</span>"<span style="color: blue;">ready</span>"<span style="color: blue;"> </span><span style="color: red;">ref</span><span style="color: blue;">=</span>"<span style="color: blue;">$layout</span>"<span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">event__layout_ready</span>"<span style="color: blue;">></span> </span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> <</span><span style="color: #a31515;">script</span><span style="color: blue;"> </span><span style="color: red;">contentType</span><span style="color: blue;">=</span>"<span style="color: blue;">application/x-javascript</span>"<span style="color: blue;">></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> </span>Script.Body_readyLayout(this);</span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"> <span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> </</span><span style="color: #a31515;">event</span><span style="color: blue;">></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> <</span><span style="color: #a31515;">subform</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Calendar</span>"<span style="color: blue;"> </span><span style="color: red;">use</span><span style="color: blue;">=</span>"<span style="color: blue;">#Calendar</span>"<span style="color: blue;">></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> <</span><span style="color: #a31515;">bind</span><span style="color: blue;"> </span><span style="color: red;">match</span><span style="color: blue;">=</span>"<span style="color: blue;">none</span>"<span style="color: blue;"> </span><span style="color: red;">ref</span><span style="color: blue;">=</span>""<span style="color: blue;">/></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> </span></span></span><span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"><</span><span style="color: #a31515;">keep</span><span style="color: blue;"> </span><span style="color: red;">intact</span><span style="color: blue;">=</span>"<span style="color: blue;">contentArea</span>"<span style="color: blue;">/></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> </</span><span style="color: #a31515;">subform</span><span style="color: blue;">></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"> <</span><span style="color: #a31515;">occur</span><span style="color: blue;"> </span><span style="color: red;">min</span><span style="color: blue;">=</span>"<span style="color: blue;">0</span>"<span style="color: blue;"> </span><span style="color: red;">max</span><span style="color: blue;">=</span>
"<span style="color: blue;">-1</span>"<span style="color: blue;">/></span></span></span><br />
<span style="font-family: "Courier New", Courier, monospace;"><span style="font-size: x-small;"><span style="color: blue;"></</span><span style="color: #a31515;">subform</span><span style="color: blue;">></span></span></span> <br />
<br />
Notice the <span style="font-family: Courier New;"><span style="color: red; font-size: x-small;">use</span><span style="color: blue; font-size: x-small;">=</span><span style="font-size: x-small;">"</span><span style="color: blue; font-size: x-small;">#Calendar</span><span style="font-size: x-small;">"</span></span>, this adds a reference to the calendar form objects. You can move form objects to the (Reference Objects) node by dragging them from higher up in the hierarchy palette down. Once there you then have to add an id attribute in the XML Source view, it is the value in the id attribute that you use in the <span style="color: red; font-family: Courier New; font-size: x-small;">use</span> above (also added in the XML Source view). Once the <span style="color: red; font-family: Courier New; font-size: x-small;">use</span> attribute has been added all the form objects will appear in the hierarchy palette, but using them to select and edit properties can cause them to be bleed back into your form. This can be useful at times when you need to override some properties but can easily cause some very strange behaviour.<br />
<h3>
Color Picker</h3>
This sample also contains a color picker. This has been implemented as a custom dialog using the app.execDialog() method.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-6l5akeWhMR0/U6ghagGCujI/AAAAAAAAALs/8Yz7JcEXxLo/s1600/ColorPicker.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-6l5akeWhMR0/U6ghagGCujI/AAAAAAAAALs/8Yz7JcEXxLo/s1600/ColorPicker.PNG" height="255" width="320" /></a></div>
<br />
This would look a lot better if I could reduce the amount of padding between the controls, but I haven't found a way of doing that. It would also be a lot better if the images showed up in Acrobat / Reader version 11.0.7, in those version you will just have to enter the decimal values for red, green and blue.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-2759989841509281612014-04-23T06:27:00.001-07:002014-04-23T06:28:02.630-07:00Adobe LiveCycle Designer Tip #4 - Setting BreakpointsDebugging a Designer form can be frustrating for people used to other environments. With a Designer form you often have to add console.println(...) calls to your code so you can work out what is going on. However, you can do most of the things you expect with a debugger, but there are a few tricks.<br />
<br />
First you can only debug JavaScript, there is no support for debugging FormCalc scripts. Second, you can only set breakpoints in event handlers, you can step into a script object but you can't set a breakpoint in one and the JavaScript debugger will not show you the code being debugged. It will at least show you which line number you are on and the JavaScript debugger console will allow you to display the values of form object properties and variables.<br />
<br />
To set a breakpoint you must open the form in Acrobat, the Preview PDF within Designer does not seem to support all the debugging functionality available. The simplest way to do this is to perform a Preview PDF, Designer will generate a temporary file in your temp directory with a random name. So in Adobe Acrobat you can go File ... Open ... then type "<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">%temp%</span>" (without the quotes) in the File name field click the open button and find the most recent PDF file with a randomly generated name something like "<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">_165o26cev28fbb2ut.pdf</span>".<br />
<br />
Once open in Acrobat the JavaScript debugger will now display the Hierarchy of the form, you will be able the expand the XFA node and navigate to a piece of event code and set a breakpoint, like this one on line 2 of the validate event of TextField1, just click where the red dot is.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-UHAxU87X8a8/U1euU_L_m4I/AAAAAAAAAKE/LPzmzzdHt70/s1600/JavaScript+Debugger+Scripts.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-UHAxU87X8a8/U1euU_L_m4I/AAAAAAAAAKE/LPzmzzdHt70/s1600/JavaScript+Debugger+Scripts.PNG" height="311" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
To see all the breakpoints you have set select BreakPoints in the Inspect: drop down (which will have defaulted to Local Variables), this will display all the current breakpoints, in this case we only have one so it looks like;<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-rHwos9GJAO0/U1evqLCiR2I/AAAAAAAAAKM/Gvx35ype4CY/s1600/JavaScript+Debugger+Breakpoints.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-rHwos9GJAO0/U1evqLCiR2I/AAAAAAAAAKM/Gvx35ype4CY/s1600/JavaScript+Debugger+Breakpoints.PNG" height="268" width="400" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
If you want to make the breakpoint conditional, select the breakpoint and click the edit button; <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ANpecSBtyIY/U1ewfIdqd4I/AAAAAAAAAKU/lhJf8VLlIec/s1600/Edit+Button.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-ANpecSBtyIY/U1ewfIdqd4I/AAAAAAAAAKU/lhJf8VLlIec/s1600/Edit+Button.PNG" /></a></div>
<br />
<br />
<br />
This will bring up a "change the breakpoint condition to:" dialog, like;<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-FvgBITHMVMc/U1exNaTO-PI/AAAAAAAAAKg/J9fXvoHGsfc/s1600/Breakpoint+Condition.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-FvgBITHMVMc/U1exNaTO-PI/AAAAAAAAAKg/J9fXvoHGsfc/s1600/Breakpoint+Condition.PNG" height="146" width="320" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
The default condition is true (so always breaks) but you can enter any JavaScript expression that resolves to true or false. So in this example we could type <span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">this.rawValue.length == 3</span> and the breakpoint will only be hit when we validate the field and it has a three character long value.<br />
<br />
You can also list all the breakpoints using the JavaScript console. In the View drop down select console and type the following (to execute select the snippet and use the Ctrl-Enter on the numeric keypad);<br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">for ( var i = 0; i < dbg.bps.length; i++ )<br />{<br /> console.println(dbg.bps[i].toSource());<br />}</span></div>
<br />
This will display something like;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">({fileName:"XFA:form1[0]:Page1[0]:Field[0]:TextField1[0]:validate", lineNum:2, condition:"this.rawValue.length == 3"})</span><br />
<br />
Then you can use the following to clear the breakpoint<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">dbg.cb({fileName:"XFA:form1[0]:Page1[0]:Field[0]:TextField1[0]:validate", lineNum:2})</span><br />
<br />
And to set the breakpoint again you can use;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: xx-small;">dbg.sb({fileName:"XFA:form1[0]:Page1[0]:Field[0]:TextField1[0]:validate", lineNum:2, condition:"this.rawValue.length == 3"})</span><br />
<br />
The<a href="http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Acrobat11_HTMLHelp&file=JS_API_AcroJS.89.344.html" target="_blank"> <span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">dbg</span></a> object also has methods for step into, step over, step out, etc but it is generally easier to use the toolbar of the JavaScript Debugger.<br />
<br />
<h4>
Watches</h4>
In the Inspect drop down there is also a Watches option this will allow you to enter any form object property or variable and watch the value change as you step thought your code.<br />
<h4>
</h4>
<br />
<br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com5tag:blogger.com,1999:blog-7970679050025899967.post-52519350201001685292014-04-12T05:08:00.001-07:002020-12-30T21:06:36.918-08:00Programmatically updating Rich Text (or xHTML)In a previous <a href="http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2014/02/adding-values-of-form-to-email.html" target="_blank"><span style="color: blue;">sample</span></a> I gave an example of updating the rich text of a draw object using E4X. In this sample I want to show an alternative using the <a href="http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.1168.html" target="_blank"><span style="color: blue;">Span</span></a> objects from the Adobe Reader API. <br />
<br />
The Span object does not cater for all the attributes of rich text that are supported in an XFA form but sometimes can be easier than using E4X.<br />
<br />
So an example, the rich text "Please click the <span style="color: red;">red</span> button" is generated by the xHTML;<br />
<br />
<span style="font-size: x-small;"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: blue; letter-spacing: -0.05pt;"><</span><span style="color: #a21313; letter-spacing: -0.05pt;">body</span><span style="color: #a21313; letter-spacing: -0.8pt;"> </span><span style="color: red; letter-spacing: -0.05pt;">xmlns</span><span style="color: blue; letter-spacing: -0.05pt;">=</span><span style="color: black; letter-spacing: -0.05pt;">"<a href="http://www.w3.org/1999/xhtml"><span style="color: blue; text-decoration: none; text-underline: none;">http://www.w3.org/1999/xhtml</span></a>"</span><span style="color: black; letter-spacing: -0.85pt;"> </span><span style="color: red; letter-spacing: -0.15pt;">xmlns:xfa</span><span style="color: blue; letter-spacing: -0.15pt;">=</span><span style="color: black; letter-spacing: -0.15pt;">"<a href="http://www.xfa.org/schema/xfa-data/1.0/"><span style="color: blue; text-decoration: none; text-underline: none;">http://www.xfa.org/schema/xfa-data/1.0/</span></a>"</span><span style="color: blue; letter-spacing: -0.15pt;">></span><span style="color: black;"><o:p></o:p></span></span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial, Helvetica, sans-serif;">
<span style="color: blue; letter-spacing: 0.1pt;"> <</span><span style="color: #a21313; letter-spacing: 0.1pt;">p</span><span style="color: red; letter-spacing: -0.1pt;"> style</span><span style="color: blue; letter-spacing: -0.1pt;">=</span><span style="color: black; letter-spacing: -0.1pt;">"</span><span style="color: blue; letter-spacing: -0.1pt;">letter-spacing:0in</span><span style="color: black; letter-spacing: -0.1pt;">"</span><span style="color: blue; letter-spacing: 0.1pt;">><o:p></o:p></span></span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial, Helvetica, sans-serif;">
<span style="letter-spacing: -0.35pt;"> Please</span><span style="letter-spacing: -0.9pt;"> </span><span style="letter-spacing: -0.1pt;">click</span><span style="letter-spacing: -0.55pt;">
</span><span style="letter-spacing: -0.2pt;">the<span style="color: blue;"><</span><span style="color: #a21313;">span</span></span><span style="color: #a21313; letter-spacing: -0.95pt;"> </span><span style="color: red; letter-spacing: -0.1pt;">style</span><span style="color: blue; letter-spacing: -0.1pt;">=</span><span style="color: black; letter-spacing: -0.1pt;">"</span><span style="color: blue; letter-spacing: -0.1pt;">color:#ff0000</span><span style="color: black; letter-spacing: -0.1pt;">"</span><span style="color: blue; letter-spacing: -0.1pt;">></span><span style="color: black; letter-spacing: -0.1pt;">red</span><span style="color: blue; letter-spacing: -0.1pt;"></</span><span style="color: #a21313; letter-spacing: -0.1pt;">span</span><span style="color: blue; letter-spacing: -0.1pt;">></span><span style="color: black; letter-spacing: -0.1pt;">button</span><span style="color: black;"><o:p></o:p></span></span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial, Helvetica, sans-serif;">
<span style="color: blue; letter-spacing: 0.1pt;"> </</span><span style="color: #a21313; letter-spacing: 0.1pt;">p</span><span style="color: blue; letter-spacing: 0.1pt;">><o:p></o:p></span></span></span><br />
<span style="font-size: x-small;"><span style="font-family: Arial, Helvetica, sans-serif;">
<span style="color: blue; letter-spacing: -0.05pt;"><</span><span style="color: blue; letter-spacing: 0.1pt;">/</span><span style="color: #a21313; letter-spacing: -0.05pt;">body</span><span style="color: blue; letter-spacing: 0.1pt;">></span></span></span><br />
<br />
As an array of Spans objects this is represented as<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">({text:"Please click the "})<br />({text:"red", textColor:["RGB", 1, 0, 0]})<br />({text:" button"})</span><br />
<br />
Then the code to change all the red text to green would be;<br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> spans <span style="color: blue;">=</span> util.xmlToSpans(Text1.value.exData[<span style="color: orange;">"##xHTML"</span>].saveXML()); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">for</span> (<span style="color: blue;">var</span> i <span style="color: blue;">=</span> 0; i < spans.length; i<span style="color: blue;">++</span>)<br />{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> <span style="color: blue;">if</span> (spans[i].textColor <span style="color: blue;">&&</span> color.equal(spans[i].textColor<span style="color: blue;">,</span> color.red))<br /> {</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> spans[i].textColor <span style="color: blue;">=</span> color.green; </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> spans[i].text <span style="color: blue;">=</span> <span style="color: orange;">"green"</span>;<br /> }<br />}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> xHTML <span style="color: blue;">=</span> util.spansToXML(spans);<br />Text1.value.exData.loadXML(xHTML, <span style="color: blue;">false</span>, <span style="color: blue;">true</span>);</span></div>
<br />
The <a href="http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.264.html" target="_blank"><span style="color: blue;">color</span></a> object used in this code is also from the Adobe Reader API, it defines some common colors (that is <span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">black, white, dkGray, gray, ltGray, red, green, blue, cyan, magenta and yellow</span>). As well as the <span style="font-family: Courier New; font-size: x-small;">color.equal()</span> method it also has a <span style="font-family: Courier New; font-size: x-small;">color.convert()</span> method so to change all the colors to a gray scale we could;<br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> spans <span style="color: blue;">=</span> util.xmlToSpans(Text1.value.exData[<span style="color: orange;">"##xHTML"</span>].saveXML()); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">for</span> (<span style="color: blue;">var</span> i <span style="color: blue;">=</span> 0; i < spans.length; i<span style="color: blue;">++</span>)<br />{</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> <span style="color: blue;">if </span>(spans[i].textColor)<br /> {<br /> spans[i].textColor <span style="color: blue;">=</span> color.convert(spans[i].textColor, <span style="color: orange;">"G"</span>);<br /> }</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">}</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> xHTML <span style="color: blue;">=</span> util.spansToXML(spans);<br />Text1.value.exData.loadXML(xHTML, <span style="color: blue;">false</span>, <span style="color: blue;">true</span>);</span></div>
<br />
If anyone still needs to have a color form for the screen and a black and white version for printing and uses rich text then this code could go in the prePrint event and then in the postPrint event you could revert to the original formatting with;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Text1.nodes.remove(Text1.value);</span><br />
<blockquote class="tr_bq">
Removing the changes made in the Form DOM resets the properties to their initial values as defined in the Template DOM.</blockquote>
<br />
To build a rich text value from scratch we could;<br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> </span><span style="font-family: 'Courier New', Courier, monospace; font-size: x-small; line-height: 13px;">spans</span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"> <span style="color: blue;">=</span> []; </span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small; line-height: 13px;">spans</span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">.push({text:<span style="color: orange;">"Hello "</span>}); </span><br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: x-small; line-height: 13px;">spans</span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">.push({text:NameField.rawValue, fontWeight:700, fontStyle:<span style="color: orange;">"italic"</span>});<br /> </span><span style="font-family: 'Courier New', Courier, monospace; font-size: x-small; line-height: 13px;">spans</span><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">.push({text:<span style="color: orange;">", I hope you like this sample"</span>}); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> xHTML <span style="color: blue;">=</span> util.spansToXML(spans); </span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Text1.value.exData.loadXML(xHTML, <span style="color: blue;">false</span>, <span style="color: blue;">true</span>);</span></div>
<br />
If you need to change a plain-text Text field into a rich-text one then you can use the following code;<br />
<br />
<div style="line-height: 1;">
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">if</span> (Text1.value.oneOfChild.className <span style="color: blue;">===</span> <span style="color: orange;">"text"</span>)<br />{<br /> Text1.value.nodes.remove(Text1.value.text);<br /> <span style="color: blue;">var</span> exDataNode <span style="color: blue;">=</span> xfa.form.createNode(<span style="color: orange;">"exData"</span>);<br /> Text1.value.nodes.append(exDataNode);<br />}</span></div>
<br />
The sample <a href="https://drive.google.com/uc?export=download&id=1bcWNovlK6Hc_JrGufVgk7S5Pke2zuTDb" ><span style="color: blue;">SpanDemos.pdf</span></a> includes a couple of other simple examples, as well as a more complicated example that will take the body element of the rich text then format and colorize it. This sample also shows a workaround for the lack of support for the <span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">xfa-spacerun:yes</span> style attribute in the Span objects.<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"></span><br />
<br />
<h4>
background-color style attribute</h4>
This attribute is not mentioned in the XFA spec and there is no support for it with the Designer UI but Reader will render the background color, you just need to enter it in the XML Source view. The trick with using <span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">background-color</span> is that all elements following the one the style is applied to will inherit the color. In an HTML page only the descendent elements would inherit the color. This just means you need a second <span style="font-family: Courier New; font-size: x-small;">background-color</span> style attribute to reset the color. Designer doesn't play well with this attribute as every time you edit the text using the Design view you will have to add the second <span style="font-family: Courier New; font-size: x-small;">background-color</span> style attribute back.<br />
<br />
The color can be specified in hexadecimal or decimal;<br />
<br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">background-color:#C4C4C4</span> or <span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">background-color:rgb(196,196,196)</span><br />
<span lang="EN-AU"></span><br />
You can see an example of the <span style="font-family: Courier New; font-size: x-small;">background-color</span> style attribute in this sample. <br />
<br />
I haven't gone though all the style attributes to see which ones are supported, but I did try adding a border and that didn't work for me.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com14tag:blogger.com,1999:blog-7970679050025899967.post-50341644729285273492014-03-27T05:34:00.000-07:002014-04-12T05:09:29.900-07:00Using the util.print methodsGenerally we can you display patterns to for formatting but there are times when we have to format values in code, and there are three handy methods in the Adobe Reader API;<br />
<br />
<table style="border-collapse: collapse; border-color: rgb(170, 188, 254); border-spacing: 0; table-layout: fixed; width: 100%;">
<tbody>
<tr>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px 50px 2px 2px;"><a href="http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.1256.html" rel="nofollow" target="_blank"><span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">util.printd()</span></a></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px 50px 2px 2px;">for dates</td>
</tr>
<tr>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px 50px 2px 2px;"><a href="http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.1257.html" rel="nofollow" target="_blank"><span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">util.printf()</span></a></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px 50px 2px 2px;">for numbers</td>
</tr>
<tr>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px 50px 2px 2px;"><a href="http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.1258.html" rel="nofollow" target="_blank"><span style="color: blue; font-family: "Courier New", Courier, monospace; font-size: x-small;">util.printx()</span></a></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px 50px 2px 2px;">for text</td>
</tr>
</tbody></table>
<br />
Here are some samples of using these methods;<br />
<br />
<table style="border-collapse: collapse; border-color: rgb(170, 188, 254); border-spacing: 0; table-layout: fixed; width: 100%;">
<thead>
<tr>
<th style="border: 1px solid rgb(170, 188, 254); padding: 2px; text-align: left; width: 50%;">Code</th>
<th style="border: 1px solid rgb(170, 188, 254); padding: 2px; text-align: left; width: 20%;">Output</th>
<th style="border: 1px solid rgb(170, 188, 254); padding: 2px; text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var</span> v <span style="color: blue;">=</span> util.printx(<span style="color: orange;">">?<*"</span>,<span style="color: orange;">"ADOBE"</span>)</span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">console.println(v)</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Adobe</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">This changes the first character (represented by the ?) to uppercase (represented by the >) and all trailing characters (represented by the *) to lowercase (represented by the <)</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var<span style="color: black;"> v <span style="color: blue;">=</span> util.printx(</span><span style="color: orange;">"9999999999"</span><span style="color: black;">,</span><span style="color: orange;">"My phone number is (02) 1111 2222"</span><span style="color: black;">)<br />console.println(v)</span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">0211112222</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">Copies the first 10 digits, skipping any others characters</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var <span style="color: black;">v</span> = <span style="color: black;">util.printd(</span><span style="color: orange;">"mmmm</span><span style="color: black;"><span style="color: orange;">"</span>,</span>new<span style="color: black;"> Date())</span></span><span style="color: black;">console.println(v)</span></span><br />
<span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"></span><br /></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">March</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">Prints the current month in full.</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var <span style="color: black;">v</span> = <span style="color: black;">util.printd(</span><span style="color: orange;">"dddd</span><span style="color: black;"><span style="color: orange;">"</span>,</span>new<span style="color: black;"> Date())</span></span><span style="color: black;">console.println(v)</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">Thursday</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">Prints the current day of the week in full</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: black;"><span style="color: blue;">var</span> v <span style="color: blue;">=</span> util.printd(<span style="color: orange;">"date.short(){}"</span>,new Date(),<span style="color: blue;">true</span>);<br />console.println(v)</span><span style="color: black;"></span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">27/03/14</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">Prints the date in the same format as the "datetime.short{}" display pattern. The actual output will vary depending on the current locale.</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var <span style="color: black;">v</span> = <span style="color: black;">util.printd(</span><span style="color: orange;">"date(fr){MMMM}"</span>,new <span style="color: black;">Date(),</span>true)<span style="color: black;"></span></span><span style="color: black;">console.println(v)</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">mars</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">Prints the current month in French</td>
</tr>
<tr><td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;"><span style="color: blue;">var <span style="color: black;">v</span> = <span style="color: black;">util.printf(</span><span style="color: orange;">"%,105d"</span><span style="color: black;">,</span> <span style="color: orange;">2</span></span><span style="color: black;">)</span><span style="color: black;">console.println(v)</span></span></span></span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;"><span style="font-family: "Courier New", Courier, monospace; font-size: x-small;">00002</span></td>
<td style="border: 1px solid rgb(170, 188, 254); padding: 2px;">Prints the number 2 in a width of 5 characters with "0" characters padding</td>
</tr>
</tbody></table>
<br />
<br />BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0tag:blogger.com,1999:blog-7970679050025899967.post-69812755367496124572014-02-28T20:09:00.001-08:002020-12-30T21:10:31.347-08:00Updated: Drop-Down List Control with auto-complete (Searchable Drop-Down List)I have made some changes to my "<a href="http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2013/05/drop-down-list-control-with-auto.html">Drop-Down List Control with auto-complete</a>" sample. <br />
<br />
To start I would like to explain the title of this sample, as it is really a textbox pretending to be the UI portion of the drop down list and a textbox pretending to be the list portion of drop down list. I am not sure what I would have called the sample but "Drop-Down List Control with auto-complete" and "Searchable Drop-Down List" came from the title of the first two <a href="http://forums.adobe.com/community/livecycle/livecycle_modules_and_development_tools/livecycle_designer_es?view=discussions">forum</a> posts I tried to answer with this sample. It seems we can't update the entries in a drop down list when the list is open, which is why I have tried to mimic the behaviour with these two controls.<br />
<br />
The changes I have made are;<br />
<ul>
<li>Display the list when the user enters the field, so the user knows this field is special</li>
<li>Show some <a href="http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2013/05/problem-ghost-text-is-common-way-of.html">"ghost text"</a>, giving instructions to the user</li>
<li>Sort the values in the list</li>
<li>Allow for <a href="http://blogs.adobe.com/formfeed/2009/02/scope_of_javascript_objects.html">strict scoping</a></li>
<li>Allow for keyboard users, previous the sample only worked with the mouse.</li>
</ul>
<h4>
To use this in your own form</h4>
<ul>
<li>Copy the subform DropDownList to you own form</li>
<li>If you don't want the option to match first characters/match any characters the delete the RadioButtonList under the DropDownList subform. You may need to update the code in the initialise event of DropDownList subform to set the default option, currently it defaults to match first characters.</li>
<li>Change the null display pattern in the Search textbox, to suit the items you are search over. This is how the "ghost text" is implemented and currently says "'Search by country name".</li>
<li>Update the code in the change event of the Search textbox, this is where the matching is performed against the list of countries. The format of the countries XML list is;</li>
<ul>
<li><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;"><Country> </span></span><br />
<span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">
</span></span><span style="font-size: x-small;"></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;"> <Region>Oceania</Region></span></span><br />
<span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">
</span></span><span style="font-size: x-small;"></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;"> <Code>36</Code></span></span><br />
<span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">
</span></span><span style="font-size: x-small;"></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;"> <Name>Australia</Name></span></span><br />
<span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;">
</span></span><span style="font-size: x-small;"></span><span style="font-size: x-small;"> </span><span style="color: green; font-size: x-small;"><span style="color: green; font-size: x-small;"> </Country></span></span></li>
<li>So the binding expression for match first characters is; <br />
<span style="font-size: xx-small;"><span style="font-family: "Courier New", Courier, monospace;"><span style="color: #ff6600;"><span style="color: #ff6600;">'$record.Country.[Lower(Left(Name,'</span></span> <span style="color: blue;"><span style="color: blue;">+</span></span> (xfa.event.newText.length) <span style="color: blue;"><span style="color: blue;">+</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">')) == "'</span></span> <span style="color: blue;"><span style="color: blue;">+</span></span> xfa.event.newText.toLowerCase() <span style="color: blue;"><span style="color: blue;">+</span></span> <span style="color: #ff6600;"><span style="color: #ff6600;">'"]'</span></span></span></span></li>
<li><span style="color: black; font-family: Times New Roman; font-size: small;">This matches the left characters of the Name element against the characters entered in the Search textbox, <span style="font-family: Courier New; font-size: x-small;">xfa.event.newText</span>. A case insensitive match is made by calling toLowerCase() on the <span style="font-family: Courier New; font-size: x-small;">xfa.event.newText</span> and calling the FormCalc function Lower on the Name element. I find the using FormCalc in binding expressions to be about four times faster.</span></li>
</ul>
</ul>
<h4>
The sample</h4>
For a PDF version of the sample with the countries data already imported download <a href="https://drive.google.com/uc?export=download&id=1J1R3vkJmqvtzrs2qVLBDhz6AhIlF6M5L">CountriesV2.pdf</a>. For the XDP template download <a href="https://drive.google.com/uc?export=download&id=1KFqrsN-ycNtTOTC-XiqbywRDltebIfMn">CountriesV2.xdp</a> and the preview data <a href="https://drive.google.com/file/d/1sKe-2FSeEpZhUFEUcOo_1UiErH-3ZzxZ/view?usp=sharing">Countries.xml</a>.<br />
<br />
BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com29tag:blogger.com,1999:blog-7970679050025899967.post-4981491013459483002014-02-09T01:04:00.001-08:002020-12-30T21:11:22.284-08:00Listing all fields in a form - The macro<a href="http://www.blogger.com/profile/16208021869177153799">Radzmar</a> has written a macro that makes <a href="http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2014/01/listing-all-fields-in-form.html">Listing all fields in a form</a> method I described in a previous blog a lot easier.<br />
<br />
The macro contains the XSLT so you no longer need to copy it around and the macro also resolves the namespace so the XSLT will work for all Adobe Reader target versions.<br />
<br />
Run the macro and you will be prompted to save the XML file that can be opened into Microsoft Excel as an XML table, without having to make temporary changes to your XDP file.<br />
<br />
Download the macro in <a href="https://drive.google.com/uc?export=download&id=1fZ03KW9m26Qo0YVejUu-Mt0saS_wUFfG">XFAObjectList.zip</a> which contains the JavaScript of the macro and the macro.xml file Designer uses to create the Tools ... Macros menu items.BR001http://www.blogger.com/profile/02005650446661555680noreply@blogger.com0