A script fragment
contains a script object. A script object contains reusable JavaScript
functions or values that are stored separately from any particular
form object, such as a date parser or a web service invocation.
Typically, you use the script objects to create custom functions
and methods that you want to use in many locations on a form. Using
script objects reduces the overall amount of scripting required
to perform repetitive actions.
Script fragments include only script objects that appear as children
of variables in the Hierarchy palette. Fragments cannot contain
scripts that are associated with other form objects, such as event
scripts like validate, calculate, or initialize.
You create a script fragment from the Hierarchy palette.
You edit script fragments the same way as other fragments.
Script fragment properties
When
you select a script fragment, the Script Object tab in the Object
palette displays the fragment properties.
Source File
Sets the source file for the fragment reference.
This property is visible only when the selected object is a fragment
reference.
Fragment Name
Sets the name of the fragment. You can click the
Frag Info button
to
view the fragment information.
This property is visible when
a fragment reference or a fragment that is defined in a source file
is selected. When the selected object is a fragment reference, this property
does not appear if the source file is not specified. The Fragment
Name list includes all the fragments in the specified source file.
The Custom option directly supports setting a SOM expression or
an ID value as the fragment reference and supports the implementation
in the XML Forms Architecture.
To create a script fragment
You can create a script fragment
of common functions that you can reuse in multiple forms. To create
a script fragment, you create a script object that contains the
functions that you want to reuse in multiple form designs. The script fragment
can include only one script object.
-
Create a script object.
-
In the Hierarchy palette, right-click the script object and
select Fragments > Create Fragment.
Note:
You
can also create a script fragment by dragging the script object
from the Hierarchy palette to the Fragment Library palette.
-
To use a different fragment name, in the Name box, type a
name for the fragment.
-
(Optional) In the Description box, type a description of
the fragment.
-
Select a method for creating the fragment:
-
To define the fragment in a separate XDP file that is stored
in the Fragment Library, select Create New Fragment In Fragment
Library. In the Fragment Library list, select the Fragment Library
in which to save the fragment file. To use a different file name,
in the File Name box, type the file name for the fragment. If you
do not want to replace the selection with the new fragment, deselect
Replace Selection With Reference To New Form Fragment.
-
To define the fragment in the current file, select Create
New Fragment in Current Document.
-
Click OK.
To insert a script fragment
You
can use script fragments to reuse JavaScript functions in multiple
forms. When creating a form design, you insert a reference to an
existing script fragment and the fragment appears in the form design.
You cannot insert a fragment in an XFAF document.
Note:
To preview the fragments in the Fragment Library
palette, select Show Preview Pane from the palette menu.
To insert a script fragment from the Fragment Library palette:
-
In the fragment library, select the script fragment.
-
Drag the fragment to a subform or variables object in the
Hierarchy palette.
To insert a script fragment from the Insert menu:
-
Select Insert > Fragment.
-
Navigate to the file that contains the fragment.
-
Select the file and click OK. The fragment appears as a child
of the variables object in the root subform
|
|
|