Professional Documents
Culture Documents
Note: Custom extension development requires advanced knowledge of SBM, XML, and JavaScript. For customers
with current maintenance contracts, Serena Software will support the infrastructure for creating custom
extensions and importing them into SBM Composer; however support for developing and packaging customer
extensions is not provided as part of the maintenance agreement.
What’s the difference between Form Extensions and Custom Form Actions?
Earlier versions of SBM contained a feature that permitted custom form actions to be defined by Serena
solution developers and added to the list of available form action Events, Conditions and Actions. The
form extensions feature builds on this solution-developer-only capability, adding the ability to define
and add custom widgets to the form palette, along with the new ability to include additional assets in
the package. The assets features allows a Form Extension to include JavaScript, CSS, Image and HTML
files deployed along with the application and used in the implementation of a custom widget.
Unlike the earlier custom form actions, form extensions can be added and removed from an application
by any Composer user and multiple form extensions can be added to an application. (Previously, custom
form actions could be added or removed from an application only by a solution developer and were
represented by a single file.) Existing form action extensions defined by solution developers can be
easily converted into form extensions because they are defined by a subset of the form extension
format.
While Composer Extensions can be imported, exported and used by any Composer user, the creation of
them is a programming task that is not generally available to Composer users. However, when the
solution developer key has been added to the registry, the files in the extension become editable in
Composer.
HKEY_CURRENT_USER\Software\Serena\Studio\Solution Developer
Value: Enabled
Type: REG_SZ
Data: True
You can directly edit the Name, Revision, Author, Copyright and Description properties using the Form
Extensions editor. Click on the Edit button in the Documentation panel to bring up an HTML editor for
modifying the documentation content for the extension. Click on the image associated with the form
extension to navigate to and specify an image file that represents the form extension in the Add Form
Extension dialog.
Click on the Edit Definition button in the Form Extensions editor to view and modify this basic
implementation, including the definition, JavaScript and CSS files. You can add, delete and rename files
from the form extension using this editor and easily insert the common $$assetspath and $$name tags
in the text.
The Sample Extension is a good starting point for creating your own form extension, because it
demonstrates techniques and best practices for creating an efficient and functional custom widget.
The assets directory contains additional directories and files used by the form actions and widgets, for
example, JavaScript files implementing widget behavior. These files are deployed along with the
application and are available to the widgets at runtime. The widgetIcons directory contains the icons
representing the custom widgets in the form palette. The documentation.html file is used to provide
documentation about the contents of the extension, such as a listing of the form actions and controls
supported by the extension. This appears in the documentation field of the form extension editor. The
logo.png file defines the image that appears when displaying the extension in the Add Form Extension
Copyright © 2015 Serena Software, Inc. All rights reserved.
dialog and in the form extension editor. The metadata.xml file contains information about the
extension, like name, revision, author etc. The definition.xml file defines the form actions and custom
widgets contained in the extension and includes both declarative information as well as JavaScript code.
ComposerExtensions/[ApplicationUUID]/[ExtensionName]
JavaScript and HTML that reference assets use a special tag (“$$assetpath”) that resolves to this path.
For example, to reference a JavaScript file in the javascript subdirectory of the assets path, you would
use:
<script type="text/javascript" src="$$assetpath/javascript/slideshow.js"></script>
Special $$ tags will be discussed in more detail in the definition.xml section below.
When the solution developer key is set, Composer permits the user to directly edit these properties in
the form extension editor.
causes the sample.css file located in the styles directory in the form extension assets to be included in
the form. In the form, the $$assetpath tag is resolved, and the following HTML is generated:
<link rel="stylesheet" type="text/css"
href="ComposerExtensions/[ApplicationUUID]/SampleExtension/styles/sample.css" />
The <GlobalIncludes> element differs from the <Includes> child element of the Events, Conditions,
Actions and Widgets elements because it will be added to the form whether or not a widget or form
action defined in the form extension is used on the form.
Restrictions
The <Restrictions> element contains a list of <Restriction> elements that defines selection lists that can
be used as values for menus that appear in events, conditions and actions. For example, a condition may
include a reference to whether a control is visible or hidden, while an action may include an instruction
to either show or hide a control.
Basic Example
An example of a restriction is:
<Restriction name="VisibleHidden">
<Value>visible</Value>
<Value>hidden</Value>
</Restriction>
This is used in both events and conditions and is referenced using the [VisibleHidden] notation in the
display attribute string. For example, in the base implementation the condition condition_FieldShown
has the display attribute "{Field} is [ShownHidden]".
is shown for the operator of the condition_FieldOperatorValue condition when a Field.Text field is
chosen, because the display attribute of the condition contains ‘[?]’ and the StringOperator restriction’s
for attribute contains Field.Text. This restriction is also used for the condition_ControlOperatorValue
condition when the left side is an EditControl because its display attribute (“{InputControl} [?] {?}")
contains ‘[?]’ and the StringOperator restriction’s for attribute contains EditControl.
Because the system chooses the first restriction that contains a type specification in the for attribute
that matches the left hand side control or field, each type should appear in only one restriction. In other
words, the for type specification should uniquely identify the restriction to use.
Copyright © 2015 Serena Software, Inc. All rights reserved.
RegularExpressions
The <RegularExpressions> element contains a list of <RegularExpression> elements that are used as pre-
defined values for conditions that match regular expressions. You can add new types of regular
expressions to this list to meet the domain specific needs of your application. By defining a regular
expression with the same name as an existing one, you can replace it in the list. For example, if you’d
like to offer a different date format, you can define a new <RegularExpression name=”Date”…> element.
The expression editor displays a drop down list box containing these pre-defined regular expressions as
well as a text area in which the user can specify a custom regular expression. This dialog appears as the
value editor for Conditions with a display attribute containing the {RegularExpression} notation. Because
regular expressions can contain characters that may not be valid in an XML element, the content of the
RegularExpression element should be CDATA escaped.
The name attribute is the unique identifier of the regular expression in the system.
The ignoreCase attribute specifies whether this regular expression should be case insensitive.
Valid values are “true” and “false”.
The description attribute specifies the text that will be shown in the drop down list in the regular
expression picker.
Aliases
The <Aliases> element contains a list of <Alias> elements that are used to define a text string that will be
substituted for a given display parameter when shown in the editor as unbound (i.e. when the tag has
not yet been given a value. For example, given an Alias element:
<Alias param="{StaticControl | InputControl | ActionControl | WidgetControl}">a control</Alias>
the text “a control” will automatically be substituted whenever the parameter { StaticControl |
InputControl | ActionControl | WidgetControl} is encountered in a display string for an unbound
parameter.
NOTE: The system automatically constructs human readable text for unbound parameters in a display
string, based on the Field or Control types referenced in it. The Alias element allows you to override this
default string with a custom one if needed.
Attributes
Attributes for the <Event>, <Condition>, <Action> and <Widget> elements are:
name attribute
This is a unique name for the event, condition, action or widget. (Required)
display attribute
For the <Widget> element, this is the name used to identify the widget in the form palette. For other
types, the display attribute specifies the display string to be shown in the form action editor. It should
contain display parameter references for any parameters that will be passed to the implementation. In
other words, the display attribute is a format string describing the event, condition or action, including
parameter tags that identify changeable values that will be passed to the implementation. The display
attribute is required. The following special parameter tags are supported in the display string.
o The {control type}, {field type}, {control type | field type…} parameter tags
Control types and field types can be or’ed. For example, {EditControl}, {Field.Text},
{EditControl | Field.Text}, and {StaticControl | EditControl} are all valid parameter tags. This
construct results in a drop down menu containing all available fields and controls that match
the types specified.
Field types that can appear in this construct consist of all fields that can appear on a form
and are identified by the Field.TypeName syntax. Where typename can be any of the
following:
Copyright © 2015 Serena Software, Inc. All rights reserved.
Numeric, Text, DateTime, Selection, Binary, State, User, Project,
Summation, MultipleSelection, Contact, Incident, Folder,
Relational, SubRelational, MultipleRelational, MultipleUser,
MultipleGroup
Subtypes can be specified for some field types. The following subtypes are supported:
When specifying a subtype in a parameter, only fields with the given subtypes will appear in
the menu. For example, {Field.Numeric.Integer | Field.Numeric.Float} would include
numeric fields with the attribute Integer or Float but not a Fixed Precision numeric field.
Custom Widget types are defined with a type name of “CustomWidget” and a subtype of
the widget name. For example:
CustomWidget.Slideshow
defines a value that can be resolved to any instance of the Slideshow custom widget on the
form. As with other parameter types, if the event, condition or action can act upon multiple
custom widget types, they can be combined the “|” (or) separator.
You can use any of the following parameter tags to show a value editor for a condition or
action. The editor appears when you click on the corresponding portion of the display string.
Depending on the left side of a condition, or the target of an action, displays an appropriate
menu or dialog. This tag cannot be placed first in the display string because it depends on
the selected item to the left.
A restriction is a list that appears as a drop down menu. The name of the restriction is used
inside the square brackets. The list of options is defined by the <restriction> element
described below.
The special reserved tag [?] has a special meaning. It is replaced with an appropriate
restriction list depending on the type of the field or control selected for the tag to its left in
the display string. The ‘for’ attribute of the <Restriction> element determines which
restriction will be used.
The following example, demonstrates special [?] restriction tag and the {?} the display string:
{InputControl} [?] {?}
when {InputControl} is bound, the [?] tag will allow binding from the restriction list that is
appropriate for the actual type of InputControl bound. Likewise the {?} tag will allow binding
from a value editor that is appropriate for the actual type.
category attribute
The category attribute references a Category as defined below and determines the section into
which the item will be placed in the drop down list. If no category is specified, the item will appear in
the Other category.
description attribute
The description attribute specifies the text to be displayed in the menu when choosing an Event,
Action or Condition item from the list. This is different than the display string that is shown in the
formType attribute
The formType attribute specifies the type of Form to which this Event, Condition or Action will apply.
Valid values are Edit, View, or Print. This attribute is optional and if not specified, the item will apply
to all form types. Form types can be combined with the “|” (or) operators. For example:
formType="Print | View"
- The position attribute specifies the position in the display string of the parameter being
referenced. Positions are 0-based.
- The name attribute specifies the name to be used in the javascript function prototype. This
name is what should be used to reference the parameter in the implementation.
- The replace attribute specifies whether the parameter will be replaced inline in the
implementation instead of being passed as a function prototype parameter. This attribute is
optional and if not specified defaults to false.
causes the sample.css file located in the styles directory in the form extension assets to be included in
the form. In the form, the $$assetpath tag is resolved, and the following HTML is generated:
<link rel="stylesheet" type="text/css"
href="ComposerExtensions/[ApplicationUUID]/SampleExtension/styles/sample.css" />
Widgets
Widgets defined in the definition.xml file inherit many of the properties of the events, conditions and
actions described above but also include additional elements as described below.
Attributes
The name, display, category and formType attributes for <Widget> elements are described above.
icon attribute
The icon attribute identifies the icon that will appear next to the Widget name in the form palette in
the “Custom Widget” section. It also appears in the form designer in the center of the widget. The
value should be the file name of the .ICO file in the widgetIcons directory in the form extensions
archive file.
<GlobalImplementation>
<![CDATA[
<script type="text/javascript" src="$$assetpath/javascript/SampleCustomWidget.js">
</script>
<link rel="stylesheet" type="text/css" href="$$assetpath/styles/sample.css"/>
]]>
</GlobalImplementation>
defines some HTML elements and a JavaScript variable referencing a JavaScript object. Because we want
this variable created only once when the form is loaded, it is defined in this element.
<DynamicImplementation>
<![CDATA[
<script>
g_$$name.Initialize("$$0", "$$1");
</script>
]]>
</DynamicImplementation>
calls a method on the SampleCustomWidget object instance created in the StaticImplementation above,
passing in the current values of the two parameters to the widget.
defines a property named Text. The content of that element is a call to the GetText() method on the
current instance of the object that implements the widget. Note that there is no ‘;’ in the expression as
it will be used in-line to obtain the value. You could also implement this by defining a method in the
StaticImplementation that took the widget instance name as a parameter, like GetText(widgetName).
When any of the properties you have defined change, controls that reference them may need to be
refreshed (the refresh tab, “On data change” option.) Because of this, the code that implements the
widget will need to raise a changed event when a property changes. The next section describes how to
do this.
In this example, _self._id is the name of the widget on the form and “Text” is the property name.
$$assetpath: The relative path from the form HTML directory to the root directory of the
assets after they have been deployed to AE. This resolves to
ComposerExtensions/[ApplicationUUID]/[ExtensionName].
It is used for accessing images and HTML files and referencing JavaScript and
CSS files that are deployed with the assets. This applies to the content of the
following tags:
<Include>
<Implementation>
<GlobalImplementation>
<StaticImplementation>
<DynamicImplementation>
$$name: This is the name of instance of the current widget on the form (e.g.
“TopPageSlideshow” not “Slideshow”.) It applies only in the
Copyright © 2015 Serena Software, Inc. All rights reserved.
<StaticImplementation> and <DynamicImplemenation> elements under the
<Widget> element.
In addition to these tags, the existing $$0, $$1, etc. tags are important for creating widgets and form
actions that reference them. Form actions that reference instances of widgets need to be able to
address variables that manipulate them. The widget name is typically passed in as a parameter (with the
replace="True" attribute) and used to construct a variable corresponding to the widget instance. For
example, if the <StaticImplementation> of the widget created a variable as follows:
var g_$$name = new SampleCustomWidget("$$name", "$$assetpath");
the implementation of a form action that references it could use that variable as follows:
if(g_$$0) g_$$0.DoAction();
In the widget generation, the instance name is represented by $$name and the form action’s first
parameter is the widget name, so it can be used to generated the g_[widgetInstanceName] variable.
This section demonstrates and discusses the implementation of events, conditions and actions. Consider
the following defined action named ChangeBackColor:
When
ebText changes value
If
ebText equals ‘(Empty string)’
Then
set background color of ebText to (157, 218, 78)
event_InputControlChanged("ebText", fn_ChangeBackColor)
function fn_ChangeBackColor()
{
if(condition_ControlOperatorValue("ebText", "equals", ""))
{
action_ControlBackgroundColor("ebText", "rgb(34, 177, 76)");
}
}
In most cases, the parameters specified in the Form Actions dialog appear only in these statements, and
are passed to the functions corresponding to the implementations ( event_InputControlChanged(),
condition_ControlOperatorValue() and action_ControlBackgroundColor()). (The exception is when the
replace attribute is set to true in the <Prototype> element.)
When the form is loaded, the fn_ChangeBackColor() callback is registered for the ebText control using
the event_InputControlChanged() implementation function. When the control changed event occurs,
that function is called, causing the condition to be tested using the implementation of the condition
(condition_ControlOperatorValue()), and then the action is taken using the implementation of the action
(action_ControlBackgroundColor()).
The Event
The “When” portion of this statement corresponds to the following <Event> definition:
<Event name="event_InputControlChanged" category="ControlEvents" display=
"{InputControl} changes value" description="an input control changes value">
<Prototype>
<Param position="0" name="source" />
</Prototype>
<Implementation>
<![CDATA[
AddChangeCallback( source, _actionName );
]]>
</Implementation>
</Event>
The display attribute indicates that when displayed to the user in the Form Actions dialog, the
{InputControl} tag will be replaced by a link bringing up a menu containing all valid input controls on the
form. In the example, the user has selected the ‘ebText’ control for this value. The <Prototype> element
indicates that this value should be passed as the first (position 0) parameter to the AddChangeCallback()
function.
NOTE: As a special case for Event implementations, the keyword _actionName is used as a placeholder
for the name of the generated form action function. In this way, when the code is generated, the name
of the function to be registered in the callback is automatically used in place of this keyword.
The Condition
The “If” portion of this statement corresponds to the following <Condition> definition:
<Condition name="condition_ControlOperatorValue" category="ControlConditions"
display="{InputControl} [?] {?}" description="an input control [operator] a
value">
<Prototype>
<Param position="0" name="source" />
<Param position="1" name="operator" />
<Param position="2" name="value" />
</Prototype>
<Implementation>
<![CDATA[
return evaluateControlOperatorValue( source, operator, value );
]]>
</Implementation>
</Condition>
The display attribute contains three tags. In the Form Actions dialog, the first tag, {InputControl}, is
replaced by a link bringing up a menu containing all valid input controls on the form. The second tag, [?],
is replaced by a menu contain a restriction list determined by the type of the first parameter. (See the
section below on <Restrictions> for more details on how this is done. ) The third tag {?} is replaced by
link bringing up a value editor corresponding to the type of the first parameter. The values the user
specifies for these tags are used as parameters to the condition_ControlOperatorValue() function call
according to the <Param> elements in the <Prototype> element.
The display attribute contains two tags {Control} and {Color}. In the Form Actions dialog, the first tag,
{Control}, is replaced by a link bringing up a menu containing all available controls on the form. The
second tag, {Color}, is replaced a link bringing up a color picker dialog. The values selected by the user
are used as parameters to the action_ControlBackgroundColor() function according to the <Param>
elements in the <Prototype> element.
Implementation
The Implementation element defines the javascript to be executed for the Event, Condition or Action.
The implementation should reference the prototype parameters either by name or by index via the $$#
notation if the parameter is marked as replace.
Example:
It defines two parameters, {Field.Text} and {RegularExpression}. When displayed in the dropdown list,
the description value (“a text field matches a regular expression”) will be used. When selected from the
list and displayed in the editor, the system will generate the display string “a text field matches a regular
expression” when the parameters are unbound (unless an Alias is specified for either parameter). When
bound, the field/control name or value will be used instead. E.g. “Title matches /^[2-9]\d{2}-\d{3}-
\d{4}$/i”.