Tib Gi Developer Guide
Tib Gi Developer Guide
Enterprise Edition
Developer Guide
Software Release 3.9
March 2010
Important Information
SOME TIBCO SOFTWARE EMBEDS OR BUNDLES OTHER TIBCO SOFTWARE. USE OF SUCH EMBEDDED
OR BUNDLED TIBCO SOFTWARE IS SOLELY TO ENABLE THE FUNCTIONALITY (OR PROVIDE LIMITED
ADD-ON FUNCTIONALITY) OF THE LICENSED TIBCO SOFTWARE. THE EMBEDDED OR BUNDLED
SOFTWARE IS NOT LICENSED TO BE USED OR ACCESSED BY ANY OTHER TIBCO SOFTWARE OR FOR
ANY OTHER PURPOSE.
USE OF TIBCO SOFTWARE AND THIS DOCUMENT IS SUBJECT TO THE TERMS AND CONDITIONS OF A
LICENSE AGREEMENT FOUND IN EITHER A SEPARATELY EXECUTED SOFTWARE LICENSE
AGREEMENT, OR, IF THERE IS NO SUCH SEPARATE AGREEMENT, THE CLICKWRAP END USER
LICENSE AGREEMENT WHICH IS DISPLAYED DURING DOWNLOAD OR INSTALLATION OF THE
SOFTWARE (AND WHICH IS DUPLICATED IN LICENSE.PDF) OR IF THERE IS NO SUCH SOFTWARE
LICENSE AGREEMENT OR CLICKWRAP END USER LICENSE AGREEMENT, THE LICENSE(S) LOCATED
IN THE “LICENSE” FILE(S) OF THE SOFTWARE. USE OF THIS DOCUMENT IS SUBJECT TO THOSE TERMS
AND CONDITIONS, AND YOUR USE HEREOF SHALL CONSTITUTE ACCEPTANCE OF AND AN
AGREEMENT TO BE BOUND BY THE SAME.
This document contains confidential information that is subject to U.S. and international copyright laws and
treaties. No part of this document may be reproduced in any form without the written authorization of TIBCO
Software Inc.
TIB, TIBCO, TIBCO Adapter, Predictive Business, Information Bus, The Power of Now, TIBCO ActiveMatrix
BusinessWorks, are either registered trademarks or trademarks of TIBCO Software Inc. in the United States
and/or other countries.
All other product and company names and marks mentioned in this document are the property of their
respective owners and are mentioned for identification purposes only.
THIS SOFTWARE MAY BE AVAILABLE ON MULTIPLE OPERATING SYSTEMS. HOWEVER, NOT ALL
OPERATING SYSTEM PLATFORMS FOR A SPECIFIC SOFTWARE VERSION ARE RELEASED AT THE SAME
TIME. SEE THE README.TXT FILE FOR THE AVAILABILITY OF THIS SOFTWARE VERSION ON A
SPECIFIC OPERATING SYSTEM PLATFORM.
THIS DOCUMENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS.
CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE
INCORPORATED IN NEW EDITIONS OF THIS DOCUMENT. TIBCO SOFTWARE INC. MAY MAKE
IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN
THIS DOCUMENT AT ANY TIME.
THE CONTENTS OF THIS DOCUMENT MAY BE MODIFIED AND/OR QUALIFIED, DIRECTLY OR
INDIRECTLY, BY OTHER DOCUMENTATION WHICH ACCOMPANIES THIS SOFTWARE, INCLUDING
BUT NOT LIMITED TO ANY RELEASE NOTES AND "READ ME" FILES.
Copyright © 1999-2010 TIBCO Software Inc. ALL RIGHTS RESERVED.
TIBCO Software Inc. Confidential Information
1
March 2010
This chapter provides an introduction to General Interface software, which includes General
Interface Framework and General Interface Builder.
Although the installation directory is different for Enterprise Edition and Professional Edition,
the contents of the directories are the same. The figure shows the directory structure and its
contents.
This chapter provides an overview of General Interface Builder features and the user interface.
Using Palettes
Customizing the IDE
Managing Projects
Work Area Editors
Component Libraries Palette and the Online Repository
Data and Cache Management
Data Connection and Mapping
Jabber Support
General Interface Documentation
Further Information on General Interface Basics
Using Palettes
This section describes the General Interface Builder palettes that you use as you work with your
application.
For more information on projects, see Managing Projects. For definitions of toolbar buttons, see
Project Files Palette Toolbar.
These object libraries not only reduce the time required to build applications, they also allow
object behavior and look-and-feel to be easily customized.
Prototype objects can be dragged from the Component Libraries palette to any object in the
work area or to the Component Hierarchy palette. A new object of the selected type is created
as a child of the object where it's dropped if the parent object accepts children.
You can also create, manage, and share your own libraries of components. Saving a component
definition to the workspace /prototypes directory adds it to the User folder in the Component
Libraries palette. The custom component can then be reused like any other prototype
component.
The Addins folder contains any prototypes defined in an add-in, such as Charting. You can also
create your own custom add-ins. Add-ins must be enabled on the Add-Ins panel before they
display in the Addins folder. For more information, see General Interface Component Guide.
For more information on components and tutorial on custom add-ins, see the General Interface
Component Guide.
Objects can contain other objects. For example, a LayoutGrid component could include Text
Box, Label, and Button objects, as well as other components. Applications usually consist of
multiple components that work together using JavaScript logic.
Using the Component Hierarchy palette, you can select objects and then modify them using
other palettes, such as Properties Editor palette, Events Editor palette, and so on. Once you've
defined a component or object, you can also clone it to quickly make multiple copies. Objects
can also be exported to reuse in other applications or imported from another project into the
current one. For more information about working with components, see General Interface
Component Guide.
To learn more about properties in the Properties Editor palette, hover the
mouse over the property name or see General Interface GUI Property
Reference (Help > API Documentation > GUI Property Reference).
To modify a common property for multiple components, select multiple components in the
Component Hierarchy palette using Ctrl+click or Shift+click and set the property value. In the
following example, the three selected components have a common width property of 120. If
property values are different, [multiple values] displays in the value field.
The Events Editor palette, as shown in the next figure, provides a set of model events for each
object. Events are name-value pairs, where the value is a JavaScript statement.
To learn more about events in the Events Editor palette, hover the mouse over the
event name or see General Interface GUI Event Reference (Help > API
Documentation > GUI Event Reference).
For more information, see General Interface Component Guide and Associating Code with an
Event.
HTML attributes change how the component is rendered when it's displayed in the browser.
After using the Attributes Editor palette, you can view your changes in the Rendered HTML
(Read Only) view of the work area.
If, for example, you add an attribute of name foo and value bar to a block, this HTML markup
is added to the rendered HTML markup for the component selected in the Component
Hierarchy palette:
To change an existing XSL parameter, select the Value field, change the value, and press Enter.
For example, the XSL for the Matrix List prototype defines two parameters: jsx_rowbg1 and
jsx_rowbg2. These parameters control the background color of odd and even numbered rows
respectively.
To learn more about XSL parameters, see General Interface XSL Parameter Reference
(Help > API Documentation > XSL Parameter Reference).
Each open component editor maintains its own Recycle Bin, which is only visible when the
component is active. Whenever you close a component editor, close a project, choose Save and
Reload, Revert, Revert All, or navigate to another project in General Interface Builder, the
Recycle Bin is emptied and the components can't be recovered.
To delete a single component, select a component in the Live Component view or the
Component Hierarchy palette. Press Ctrl+Delete or use the Recycle button on the
Component Hierarchy palette toolbar.
To recover components from the Recycle Bin palette, choose Palettes > Recycle Bin, select the
component to recover, and click the Restore Recycled Object button on the toolbar. The
components are restored to the Component Hierarchy palette and the Live Component view.
For definitions of toolbar buttons, see Local Data Cache Palette Toolbar.
Docking options
Adjustable log levels, such as OFF, FATAL, ERROR, WARN, INFO, DEBUG, or TRACE
Support for sound for messages
Color coding of messages, such as red for error messages
For more information about logging, see Logging and Application Monitors.
3. Save logger.xml.
To open the IDE Settings dialog, choose Tools > IDE Settings.
This section discusses some but not all of the available options. For more information, see IDE
Settings Dialog.
Character Encoding
General Interface Builder provides support for writing files in a specified character encoding,
such as UTF-8 or UTF-16. The ability to choose a character encoding is particularly useful for
developing and localizing applications for multilingual environments.
General Interface Builder allows you to specify an encoding for all project files, as well as
separately specify an encoding for XML files.
General Interface Builder settings in the IDE Settings dialog allow you to:
For applications loaded from the local disk, such as General Interface
Builder, Firefox reads non-XML files that are encoded in a standard 8-bit
encoding. Firefox can read local XML files in any encoding supported by
the host system only if the encoding is included in the XML declaration.
1. Enter an encoding in the Output character encoding field. Click the Test button to verify
that the specified encoding is available on the system and can be written. If this field is
empty, the default is used. This default is system-dependent.
2. Select an output line separator. If this field is empty, the default is used. This default is
system-dependent.
3. Check the Instead encode XML file as checkbox if you want to use a different encoding
for XML files. Enter an encoding. Click the Test button to verify that the specified
encoding can be written and that it's available on the system.
If this option is unchecked, XML files are written in the same encoding as specified in the
Output character encoding field or the default system encoding if that field is empty.
4. Check the Add character encoding to XML declaration if you want the encoding in the
XML declaration.
5. Click Save or Apply to save your changes.
To revert to the default hot key, double-click a row and choose Use Default.
Paths Panel
On the Paths panel, you can set the workspace path for your projects and the HTTP base path
for running applications from a local HTTP server.
Workspace
The workspace is the directory that contains your projects, custom add-ins and prototypes, and
your user settings for General Interface Builder.
1. Open the IDE Settings dialog and click the Paths button.
2. Click the Browse button next to the Workspace field to open the Choose Folder
dialog.
3. Navigate to a folder, select it, and click Choose. Click Choose again to close the Choose
Folder dialog. You can also use the New Folder button to create a new folder.
4. Click Save to save the changes and close the IDE Settings dialog or click Apply.
5. Click OK at the Restart Required prompt and use the browser reload button to restart
General Interface Builder.
HTTP Base
The path in the HTTP Base field is used when you select Project > Run Project From HTTP. To
use this feature, you must have an HTTP web server, such as Apache, hosting both the General
Interface installation directory and your workspace directory.
To add an HTTP base, enter the base URI for the General Interface directory on a local HTTP
server. If this field is empty and you choose Project > Run Project From HTTP, you are
prompted to enter a path.
If the relative path between the workspace directory and the General Interface directory isn't
the same on the HTTP server as on disk, you must enter the relative path to the workspace
directory in the WS Path field.
Chat Panel
On the Chat panel, you can specify server and login settings for the Jabber client in General
Interface Builder. See Jabber Support.
Docking settings are saved in your user settings and reloaded each time you open General
Interface Builder.
To access docking options, click the down arrow next to the Docking Options button .
To hide all the palettes, click the Show Edit Pane button on the General Interface
Builder taskbar.
Managing Projects
All development work in General Interface Builder is done in a project in the workspace.
Projects are collections of files you create and edit in General Interface Builder. Project files are
displayed in the Project Files palette and stored in the workspace.
Choosing a Workspace
The workspace is the directory that contains your projects, custom add-ins, custom prototypes,
and your user settings for General Interface Builder.
The first time General Interface Builder launches after installation, a dialog prompts you to
create or select a workspace directory. You can create a new directory, select an existing
directory, or choose the default workspace directory. The default workspace location is
C:\Documents and Settings\username\My Documents\TibcoGI. You can use multiple
workspaces for your projects, as well as change workspaces.
Changing a Workspace
You can keep all of your projects in one workspace or use multiple workspaces. You can
modify the workspace location in the IDE Settings dialog. See Workspace.
Creating Projects
When you create a project, default files are created and opened in the work area: logic.js and
appCanvas.xml. The JavaScript file, logic.js, is an empty file that you can add JavaScript code
to. The default GUI component file, appCanvas.xml, is where you can begin designing your
application user interface.
1. Choose Project > New Project or click the Create a New Project link in the Welcome
screen (Help > Welcome Screen) to open the new project wizard.
2. Choose General Interface Application as the project type, and click Next.
A new project is loaded in the browser window. Two default, empty files are open in the
central work area.
While building this sample application, all project data is stored locally in
browser memory. The application is not automatically saved to the file
system. Save the project before you close or refresh the browser window.
If you don't save the project, the data is lost.
The top-level project folder has the same name as your project. All project folders include the
default subdirectories and files listed in the following table. This default structure can be
modified and additional folders can be created as needed. For example, you might create
folders for image, WSDL, and CSS files.
config.xml Contains application configuration data, such as project settings and file
locations. See Modifying Project Settings.
launch.html Launches the application in the web browser. Use this file only during
development, not at runtime.
launch_in_ide.html Launches the application in General Interface Builder. Use this file only
during development, not at runtime.
To access project files and folders, click the JSXAPPS/project_name link in the General
Interface Builder taskbar, located in the lower left area of the IDE.
Project Description
Folders
components Contains the XML files for application components. Each component has an
associated XML file with object definitions. For component files, use the .xml
extension. When you create a new project, a default component named
appCanvas.xml is created in this folder. See General Interface Component Guide.
js Contains included JavaScript files for your application. For JavaScript files, use
the .js extension. When you create a new project, a default file named logic.js
is created in this folder. See Adding and Debugging JavaScript Code.
jss Contains dynamic properties XML files. For dynamic properties files, use the
.xml extension. See Dynamic Properties Files.
rules Contains mapping rules XML files for connecting to web services. Rules files
define the mappings between GUI components and SOAP message elements.
For mapping rules files, use the .xml extension. See Basic Steps for
Communicating with Data Services.
xml Contains any XML files with content data, such as default values, for the
application. For XML files, use the .xml extension.
xsl Contains any XSL files used for transforming application data. For XSL files,
use the .xsl extension.
These project folder names are conventions only and not mandatory.
Saving Projects
When you save project files, General Interface Builder saves them to a project directory in the
JSXAPPS directory in the specified workspace directory. For example, workspace
/JSXAPPS/project_name. For more information on workspaces, see General Interface Getting
Started.
Right-click a file tab in the work area and choose Save, Save and Reload, or Save As.
Choose File > Save, Save and Reload, Save As, or Save All.
Copyright © TIBCO Software Inc. All Rights Reserved.
20
Choose File > Save, Save and Reload, Save As, or Save All.
For a local data cache XML file, right-click a file tab in the work area and choose Save to
Cache or Save a Copy to Disk.
Running Projects
There are several ways to run a project:
To run a project in a new browser window on a local HTTP server, choose Project > Run
Project From HTTP. If the HTTP server isn't configured, you are prompted to configure it.
Opening Projects
There are several ways to open a project:
Choose the Open an Existing Project link in the Welcome screen (Help > Welcome
Screen) and choose a project from the list.
Choose Project > User Projects and choose a project from the list. To open a General
Interface sample project, choose Project > User Projects > Samples and choose a sample
project from the list.
Choose Project > Recent Projects and choose a recently opened project from the list.
Double-click the default General Interface Builder launch file, workspace/ project_dir
/launch_in_ide.html, which is generated when you create the project. Use this file to
launch the project only during development, not at runtime.
You can also open multiple instances of the same project in different browsers, such as Internet
Explorer and Firefox. However, because each instance is sharing the same preferences and
settings files, competing changes to General Interface Builder preferences may not be persisted.
Closing Projects
To close a project, simply close the browser.
Deploying Projects
To deploy a project, set deployment options on the Deployment panel of the Project Settings
dialog. Use the Deployment Utility to create a hyperlink to the deployed application. Then copy
your application files and General Interface software to an HTTP or HTTPS web server.
Deployment Panel
Deploying Applications
You can modify the project settings in the Project Settings dialog. Any changes you make in the
Project Settings dialog are saved to the configuration file.
If you edit this file manually, close General Interface Builder before editing.
To open the Project Settings dialog, choose Project > Project Settings. To save your changes in
the Project Settings dialog, click the Apply or Save button.
Deployment Panel
Add-Ins Panel
Classpath Panel
Legacy Settings Panel
For more information on available options in the Project Settings dialog, see Project Settings
Dialog.
Deployment Panel
Settings on this panel control the behavior of the deployed application. For definitions of
options not discussed here, see Project Settings Dialog. For more information on deployment,
see Deploying Applications.
Namespace
The General Interface runtime creates a single instance of a jsx3.app.Server for each loaded
application. The application namespace, which is a unique JavaScript identifier for the
jsx3.app.Server instance, provides access to the jsx3.app.Server instance.
When specifying a namespace, it's recommended that you use the reverse-domain naming
convention with the dot symbol (.). For example com.tibco.APP. Using the reverse-domain
naming convention reduces the likelihood that other JavaScript code will interfere with your
application.
1. Choose Project > Project Settings >Deployment to open the Deployment panel of the
Project Settings dialog.
2. Type the namespace in the Namespace field. For example, set the namespace to
eg.chart.APP.
You can also override the namespace per deployment using the jsxappns deployment
parameter. See Deployment Parameters.
Mode
The deployment mode for the deployed application can be set to Live or Static mode. Select
Live mode if the application needs to be online and is connected over HTTP/S to a server for
online data access.
Select Static mode when working offline. When in offline mode, the application can't access a
server. Data is static and is referenced using static URLs stored in rules files. Choose Static
when developing and testing an application offline or when a back-end web service isn't
available.
When the Body Hot Keys option is checked on the Deployment panel, any hot key event that
bubbles up to the HTML body element is sent to the application. Even if the focus is in the
Copyright © TIBCO Software Inc. All Rights Reserved.
23
bubbles up to the HTML body element is sent to the application. Even if the focus is in the
browser window and not in the General Interface application, the application receives the hot
key and responds to it. Choose this option for deployment of standalone console applications.
See Deploying as a Full Console Application.
When the Body Hot Keys option is unchecked, hot keys only function if the focus is in the
General Interface application. This deployment choice prevents your application from
responding to hot keys initiated in other General Interface applications on the page. Choose this
option for deployment of non-console applications that are a portion of a web page. See
Deploying as a Non-Console Application.
onLoad Script
Enter one or more JavaScript statements that you want executed when the application
initializes. For example, you might want to execute a main method, communicate with a server,
create controller objects by instantiating a controller class, or create the state of the application.
For more information, see Executing Code When the Application Loads and Deployment Panel.
onUnload Script
Enter one or more JavaScript statements that you want executed when the browser window is
unloaded. The onUnload event allows you to save user state and do any final cleanup before
exiting. For more information, see Executing Code When the Application Unloads and
Deployment Panel.
Add-Ins Panel
Use the Add-Ins panel to enable the Charting add-in or custom add-ins for a project. Add-ins
are disabled by default to accelerate load time of General Interface Builder and General
Interface applications.
Enabling Add-ins
To enable add-ins,
1. Choose Project > Project Settings to open the Project Settings dialog and click Add-Ins.
2. Check the add-in you'd like to enable on the Add-Ins panel.
3. Click Save to save the changes and close the dialog or click Apply.
4. Click OK at the Restart Required prompt and use the browser reload button to restart
General Interface Builder.
After add-ins are enabled, their prototypes are available in the Component Libraries palette in
General Interface Builder.
For more information on the Charting add-in, see General Interface Component Guide.
Custom Add-ins
For custom add-ins to display on the Add-Ins panel, they must be saved to the JSX/addins or
workspace/addins directory. Typically, add-ins to be used by a team of developers would be
saved to the JSX/addins directory and posted by an administrator to a location accessible to the
team. Add-ins for individual use can be saved to the workspace/addins directory.
Classpath Panel
The project class path is used by General Interface to find custom classes that are dynamically
loaded by your application.
1. Click in the Path field and type the path to the classes.
The class path is relative to the project directory. For example, entering js/
as the path would load the specified classes in the workspace
/JSXAPPS/project_dir/js directory.
2. Press the Tab key and type the packages to load in the Packages field. For example,
com.tibco.*.
3. Press Enter to commit the class path.
4. Click Save to save the changes and close the dialog or click Apply.
5. Use the browser reload button to restart General Interface Builder for the changes to take
effect.
To delete a class path, click the Delete button next to the row.
js/ com.tibco.* Loads classes with three words beginning with com.tibco from
the directory workspace/JSXAPPS/project_dir/js. For example,
this would load the class file workspace
/JSXAPPS/project_dir/js/com/tibco/Object.js.
js-ext/ com.tibco.ext.* Loads classes with four words beginning with com.tibco.ext
from the directory workspace/JSXAPPS/project_dir/js-ext. For
example, this would load the class file workspace
/JSXAPPS/project_dir/js-ext/com/tibco/ext/Object.js.
js-foo/ com.foo.** Loads all nested classes of com.foo from the directory workspace
/JSXAPPS/project_dir/js-foo/.
js-foo2/ com.foo.*.* Loads classes with four words beginning with com.foo from the
directory workspace/JSXAPPS/project_dir/js-foo2.
GUI components
XML
XSL
JavaScript
1. Choose File > Save or Save As or right-click the file tab at the top of the work area and
choose Save or Save As.
2. Optionally, browse to the recommended directory in the project. Choose components for
GUI components, js for JavaScript, jss for dynamic properties files, xml for properties
bundle files, rules for mapping rules files, xml for XML documents, and xsl for XSL
documents.
3. Enter a file name and extension. Enter the .xml extension for GUI components, XML,
dynamic properties, and mapping rules files. Enter the .xsl extension for XSL files. Enter
the .js extension for JavaScript files and the .css extension for CSS files.
4. Choose Save to close the Save File dialog.
These views are available from the work area toolbar to the lower right of the work area as
shown in the following figure.
Grid View
The Grid view is available for dynamic properties files and properties bundle files. You can
use dynamic properties files, which are XML resource files, to create custom properties for
components. Properties bundle files are XML resource files used to localize your application for
a specific language and country.
For more information, see Dynamic Properties Files. See Properties Bundle Files and
Internationalizing and Localizing Applications.
Source View
The Source view is available for all file types and displays the editable source for XML files
and text files, such as JavaScript and CSS files. For components, the Source view displays the
XML source of the component serialization file.
When running General Interface Builder in HTML and XHTML mode, well-formed HTML,
Copyright © TIBCO Software Inc. All Rights Reserved.
27
When running General Interface Builder in HTML and XHTML mode, well-formed HTML,
which is XHTML, is pretty-printed in the Rendered HTML (Read Only) view. If the markup
isn't well-formed, pretty printing isn't used and a parsing error displays in the System Log
palette.
For example, if you entered HTML without a closing element in the Text/HTML property for a
label, such as <b>My Label, a mismatched tag error message displays in the System Log palette
and the Rendered HTML (Read Only) view isn't pretty-printed. If you entered valid XHTML
with open and close elements, such as <b>My Label</b>, no error is reported and the Rendered
HTML (Read Only) view is pretty-printed.
Here you can assign a name, description, and icon URL for the component. This is useful if
you're creating custom components and exporting them to the Component Libraries palette (
workspace / prototypes). The icon displays next to the name of the component in the
Component Libraries palette and the description displays as a tooltip.
Executing JavaScript code before an object is deserialized is useful when the runtime needs to
be prepared before the component is loaded, such as preloading data for the component.
Executing JavaScript code after an object is deserialized is useful when the component needs to
be initialized with information only available at runtime. For example, you might want to
modify the CDF for a Matrix list component and then re-populate the list after it displays
on-screen.
JavaScript code entered in the onBeforeDeserialization text area has access to the objXML context
variable, which is an instance of jsx3.xml.Document. The objXML context variable represents the
serialization file in-memory and the jsx1 namespace prefix resolves to the namespace for the
file (in this case, urn:tibco.com/v3.0).
For example, if you have a Block in your serialization file named foo and you want to change
the background color to red, you could put the following code in the onBeforeDeserialize
event:
objXML.setSelectionNamespaces("xmlns:jsx1='" +
jsx3.app.Model.CURRENT_VERSION + "'");
var objNode =
objXML.selectSingleNode("//jsx1:object\[@type='jsx3.gui.Block']/
jsx1:strings\[@name='foo']");
if(objNode) {
objNode.setAttribute("jsxbgcolor","red");
}
The onAfterDeserialize event provides direct access to the actual model objects, after they are
deserialized but before they are rendered on-screen. In this example code, the background of
Note that the objJSX variable, which is an instance of jsx3.app.Model, points to the
root object in the serialization file.
When authoring dynamic properties and properties bundle files using non-ASCII
characters and non-western languages, save the file in a format that supports such
characters, such as UTF-8 or UTF-16. See Character Encoding.
General Interface has built-in dynamic properties that you can use. These built-in dynamic
properties begin with an @ symbol. You can also create your own custom dynamic properties
files using the Dynamic Properties editor.
General Interface and custom dynamic properties are available on the context menu in the
Properties Editor palette as shown in the following figure. To assign a dynamic property,
right-click in the Properties Editor palette and select a dynamic property. You can also type the
property key (ID) in the Value cell, such as @Dialog BG for the BG Color property. After a
dynamic property is selected, the explicit value displays in the Value field next to the name of
the dynamic property.
1. Choose File > New > Dynamic Properties File. A visual editor displays in the work area.
2. Enter a name for the property in the ID field.
3. To select a type, click in the Type column and choose a type from the drop-down list or
begin typing the name, such as jsxb, to see the list of matches.
4. Enter a value for the type in the Value field. If the value is JavaScript code, check the
Eval checkbox.
Values can be text or JavaScript code. For more information on entering JavaScript code,
see Specifying Code in Dynamic Properties. For information on CSS values, see General
Interface Component Guide.
For example, you might want to add a custom color for the BG Color property. Enter a
name for the property, such as bluebgcolor. Select jsxbgcolor as the type and enter a
color value, such as #6E6CEF.
You can use the Color Picker to choose a color. Choose Tools > Color Picker or click the
Color Picker button in the Properties Editor palette.
5. Continue to edit values and do the following as needed to set up the list of properties:
To add a new row, press Enter, click the Add button , or right-click a row and
choose Insert New Record.
To delete a row, select a row and click the Delete button .
6. Choose File > Save and Reload or right-click the work area tab and choose Save and
Reload.
7. Browse to the jss folder of your project and enter a file name with the .xml extension.
For dynamic properties files, be sure to use the .xml extension as some
servers won't recognize the .jss extension used in previous releases. By
default, General Interface, version 3.2 and higher, supports the .xml
extension, which is the recommended file extension.
1. Set the dynamic properties file to automatically load with the application, so the new
Copyright © TIBCO Software Inc. All Rights Reserved.
31
1. Set the dynamic properties file to automatically load with the application, so the new
properties are always available. Right-click the dynamic properties file in the Project
Files palette and choose Auto Load.
2. Return to the Live Component View and select the component you want to apply the
property to in the Component Hierarchy palette or in the work area.
3. Find the property you added in the Properties Editor palette, such as BG Color, and
right-click the Value cell to invoke the lookup list of property values. The property value
you added displays on the list.
When authoring dynamic properties and properties bundle files using non-ASCII
characters and non-western languages, save the file in a format that supports such
characters, such as UTF-8 or UTF-16. See Character Encoding.
Properties bundle files, also known as resource bundles, contain locale-specific objects, such as
menu and button labels in the application user interface. When these strings are externalized in
the properties bundle files, it's easier to translate applications into other languages. The
application simply loads the locale-specific resource appropriate for the user's locale.
For more information on localizing, see Internationalizing and Localizing Applications.
The interface to the component repository is in the Component Libraries palette in Builder. The
Component Libraries palette includes the following tabs:
Copyright © TIBCO Software Inc. All Rights Reserved.
32
System tab: A tree that shows all of the built-in system components. These files are
stored at the path GI_HOME/GI_Builder/prototypes.
User tab: A tree that shows the components that the current user has created in their
local GI workspace. Components downloaded from GeneralInterface.org are also saved
here. These files are stored at the path GI_WORKSPACE/prototypes.
Online tab: List of the shared components that have been previously uploaded to
GeneralInterface.org.
A component must exist in the GI workspace before you can upload it to the online repository.
To save a component to the GI workspace:
To create new component folders in your workspace, click the New Folder icon and enter
the folder name. To remove components, select the components and click the Delete icon.
For each component that you upload, you must agree to the General Interface terms
of service http://www.generalinterface.org/terms.html.
1. Select the component on the User tab in the Component Libraries palette.
2. Click the Upload Component icon.
3. Enter a name and description.
4. Select the check box to agree to the General Interface terms of service. To review the
terms of service, click the underlined link.
5. Click Upload.
6. If you are not already logged in, you will be prompted to enter your user name and
password. Log in, then click Upload again.
The component is uploaded and summary infomation is presented. If you have any custom
code in the application, Dojo Foundation staff will review the code before making it available to
others.
To view an uploaded component, open the Online tab. Click the Filters icon and choose
filtering option as needed to display the component.
The Online tab of the Prototype Libraries palette supports the options described in this section.
Using Filters
The following filter options are available by clicking the Filters icon.
Function Description
Featured Show the components that the Dojo Foundation is currently featuring.
Rating Show the user ratings along with the component name.
Downloads Show the number of times that the component has been downloaded.
User Show the login name of the user who uploaded the component.
Using Feeds
The following options are available by clicking the Feeds icon. To view these options, you
must be subscribe to Live Bookmarks. If you are not subscribed, you are prompted to do so
when you first choose a Feeds option on the Online tab.
Function Description
Top Rated Show the components with the highest user ratings.
Most Popular Show the components that have been downloaded most frequently
Most Recent Show the components that were uploaded most recently
At the most basic level, a General Interface application consists of files stored on the file system.
The formats of application files are industry-standard, such as XML, XSL, and CSS. You can use
viewing and editing features built into General Interface Builder or you can use external
editors.
General Interface Builder provides the following XML editing and management features:
Access to all component XML files for inspection and updates. Buttons to the lower right
of the work area provide multiple views of each component, including an editable XML
view. Component definitions can be refreshed using the toolbar on the Component
Hierarchy palette.
Access to all cached XML and XSL files for inspection and updates. The Local Data
Cache palette allows you to view and open cached files for editing. Modified files can be
saved and reloaded with a single command.
XML/XSL Merge Tool is used for testing the text, HTML, or XML output from a merge
operation. You can view both the parsed output and its source. If parsing errors occur,
error notification is provided. You can open multiple instances of this tool.
Character-level debugging that helps you identify the location of any XML parsing
errors.
To open the XML Mapping Utility, choose Tools > XML Mapping Utility.
Copyright © TIBCO Software Inc. All Rights Reserved.
36
To open the XML Mapping Utility, choose Tools > XML Mapping Utility.
For more information on the XML Mapping Utility, see Communicating with Data Services and
Communicating with a Web Service Tutorial.
Visual Bindings
The XML Mapping Utility provides a visual interface for mapping GUI components to data
services. You can use drag-and-drop to create bindings for inbound and outbound SOAP
messages and XML documents. XML elements can be bound to the values of GUI objects, nodes
in XML documents, and JavaScript variables. All mapping information is stored in an XML file
referenced in the project. If modifications are needed, you reopen this file in the XML Mapping
Utility.
Testing
When mappings are complete, the interaction with the data service can be tested. You can
preview the outbound message before it is sent, test the message against the live service,
preview the response message, and enter a callback script to execute when the response is
received.
For General Interface feature updates and examples to assist the application development
process, visit Developer Network at http://www.generalinterface.org.
Jabber Support
General Interface Builder includes a Jabber client, allowing you to participate in chats from
within Builder. The client is implemented on top of the Dojo XMPP library. It works with Jabber
servers that support the Jabber HTTP Bind protocol, such as OpenFire.
One-to-one conversations
To configure your Jabber settings, open the IDE Settings window, as described in Customizing
the IDE.
When Jabber is configured, you can open the Chat palette from the Palettes menu.
Product documentation
Context-sensitive help
Spyglass help
API documentation
Product Documentation
Product documentation is available online at
http://www.generalinterface.org/docs/display/DOC/Learning+Center.
Context-sensitive Help
To access context-sensitive help in General Interface Builder, move focus to an area of the IDE,
such as a dialog, editor, or palette, and press Alt+F1 or click the Help button .
Spyglass Help
Documentation is also available in a spyglass in various areas of General Interface Builder. A
spyglass contains descriptive text in HTML and can contain more information than a tooltip. To
invoke a spyglass, hover the mouse over the following areas in the IDE:
You can also add spyglass documentation to your own applications using the Spyglass event
(jsxspy) and the spy methods in the jsx3.gui.Interactive interface. For more information, see
General Interface API Reference.
API Documentation
Online API documentation is available online at
http://www.generalinterface.org/docs/display/DOC/API+Documentation.
The classes distributed with General Interface are partitioned into two categories:
Statically loaded classes that are always loaded by General Interface at application
startup
Dynamically loaded classes
For a list of statically loaded system classes, see General Interface Framework Classes.
Dynamically Load other General Auto Load disabled. Add Auto Load disabled.
loaded Interface classes using custom classes to class path. Load code using
jsx3.require() or Load class using Server.loadResource().
automatically with jsx3.require() or
deserialization. automatically with
deserialization.
All other system classes, such as Matrix, must be loaded dynamically using the require()
method or through deserialization. See jsx3.require() Method.
Application Classes
To statically load your application class files as the application loads, enable the Auto Load
option for the JavaScript files in the Project Files palette. For more information, see Enabling the
Auto Load Option.
To dynamically load custom application classes when the Auto Load option is off, classes must
The classes must be on the class path, so the system class loader can find the classes. See
Specifying Class Paths.
The jsx3.require() method must be used to load classes explicitly that are not loaded
automatically by the component through deserialization. See jsx3.require() Method.
Application Code
To statically load your application code as the application initializes, enable Auto Load for the
JavaScript files in the Project Files palette. For more information, see Enabling the Auto Load
Option.
If you don't want the application code statically loaded, you can load it dynamically using the
Server.loadResource() method. This method looks up a resource registered with the
application by its id. The resource must be registered in the config.xml file of the application.
For more information, see General Interface API Reference.
To enable the Auto Load option for one or more JavaScript files in your project, complete these
steps:
When you enable the Auto Load option, the onLoad attribute for the JavaScript file is set to true
in the application configuration file (config.xml).
jsx3.require() Method
The jsx3.require() method can be used to load classes explicitly. Use the fully qualified class
name when using the jsx3.require() method. For example,
jsx3.require("jsx3.net.Form");
Only classes that can be found by the system class loader are loaded. Custom classes can be
added on the Classpath panel of the Project Settings dialog. See Specifying Class Paths.
When a component file is deserialized, the class of each object encountered in the file is
dynamically loaded if it's not already loaded. Therefore, it's often not necessary to use the
jsx3.require() method with classes that descend from jsx3.app.Model. However, if JavaScript
code references these classes and if the code executes before a deserialization automatically
loads the class, you must use the jsx3.require() method to explicitly load the class.
The jsx3.require() method must be called at least once before making these types of
references:
Classes must be located in the same directory structure as the package name. See
Class Naming Conventions.
The JavaScript class file name should be identical to the class name with a .js extension. For
example, a class named SomeClass would be saved as SomeClass.js. The directory structure of
the class file must match the package name that the class is in. For example, if SomeClass.js is
in a com.tibco package and is saved to a js directory in the project, the class file location should
be js/com/tibco/SomeClass.js.
URI Resolution
This section describes how URIs are resolved in General Interface. A Uniform Resource
Identifier (URI) identifies or names a resource required by the application.
The URI functionality of General Interface has been updated to provide additional functionality
and to simplify development. Project resources are now referenced by the project configuration
file (config.xml) relative to the base directory of the project. Referencing resources in the
configuration file allows you to rename and move project directories more easily.
Any relative URI that isn't of a legacy 3.1 format (beginning with JSX/ or JSXAPPS/) is resolved
relative to a base URI that depends on the context of the URI. General Interface 3.1 applications
perform as expected in version 3.2 and higher. However, it is strongly recommended that you
update your applications to take advantage of the relative URI functionality.
JSXAPPS/appname/subfolders/filename.xml
The version 3.1 format is still valid in version 3.2 and higher, because URIs beginning with
JSXAPPS/ are handled in a special manner. As of version 3.2, these URIs can be written relative
to the base directory of the project. The previous example can now be written as follows to take
advantage of relative paths:
subfolders/filename.xml
In General Interface Builder, version 3.2 and higher, any property editable in the Properties
Editor palette can accept a relative URI, which is resolved relative to the project directory. For
example, these properties accept relative URIs: the Image property for ToolbarButton and the
XML URL property for List. URIs that appear in free form properties, such as Text/HTML for
Block, are never resolved. URIs set as values of attributes in the Attributes Editor are also not
resolved.
In summary, the URI requirements in General Interface Builder, version 3.2 and higher, include
the following:
1. All properties editable in the Properties Editor palette that expect a path (XML URL,
Image URL, and so on) can take an absolute path or a path relative to the project
directory.
2. All other inputs (HTML attributes, free-form HTML) have to be pre- resolved statically
or using the URIResolver API. See URI Resolvers.
Using dynamic properties is one way of externalizing these paths. Be certain that values stored
in the dynamic property agree with the requirements described above, depending on how they
are used.
To reference a resource that is located outside of the project directory, use a relative URI
starting with one or more "../" tokens or one of the supported absolute URI formats. See URI
Format Support.
For more information on the script element, query parameters, and deployment parameters,
see Deployment Parameters.
JSX/... Legacy format for General Interface 3.1. Resolves relative to the
parent of the JSX directory as determined by the location of the
JSX30.js script. If multiple script elements are used in one HTML
page, the URL for the JSX30.js script file must be the same.
JSXAPPS/... Legacy format for General Interface 3.1. Resolves relative to the
parent of the JSXAPPS directory, as determined by the jsxapppath
query parameter of the src attribute of the script element
referencing the JSX30.js script. If multiple script elements are used
in one HTML page, the applications must be located in the same
JSXAPPS directory.
GI_Builder/... Legacy format for General Interface 3.1. Resolves as JSX/... when
General Interface Builder is running. Applications should not
reference any URIs of this format, because the GI_Builder directory
can't be deployed under the standard licensing terms.
jsx:///... Format for General Interface 3.2 and higher. Resolves relative to the
JSX directory as determined by the location of the JSX30.js script.
jsxaddin://addin/... Format for General Interface 3.2 and higher. Resolves relative to the
base directory of the add-in specified by the host portion (addin) of
the URI. The host portion of the URI follows the double forward
slashes (//). The host of the URI should be the add-in key (
AddIn.getKey()) with any colon characters (:) replaced with an
exclamation point (!). The add-in must be loaded for the URI to
resolve correctly.
jsxuser:///... Format for General Interface 3.2 and higher. Resolves relative to the
parent of the JSXAPPS directory (workspace). When General Interface
Builder is running, this URI resolves relative to the workspace
directory.
jsxapp://app/... General Interface 3.2 and higher format. If the Server instance
corresponding to the host portion of the URI is loaded into memory,
the URI is resolved relative to the application base directory (
jsxappbase). The host portion (app) of the URI is the relative path
from the JSXAPPS directory to the application base directory
containing the config.xml file with any forward slashes (\/) replaced
with exclamation points (!). If the Server instance isn't loaded into
memory, the URI resolves relative to the directory containing the
config.xml of the application. Note: You can override the application
base directory (jsxappbase). See Overriding the Application Base
Directory.
Additionally, any URIs specifying a scheme or an absolute path (beginning with a forward
slash) are also considered absolute and will not be modified.
Any other URI is considered relative and will be resolved by a URI resolver depending on the
context in which it is encountered.
URI Resolvers
General Interface, version 3.2, introduces a new interface, jsx3.net.URIResolver. An object that
uses relative URIs must implement methods in the URIResolver interface to define a context
against which those URIs are resolved. Two classes, jsx3.app.Server and jsx3.app.AddIn,
implement this interface. The Server class uses the jsxapp: URI scheme and the AddIn class uses
the jsxaddin: URI scheme described previously. Additionally, static resolvers are provided for
the jsx: and jsxuser: schemes. For more information, see General Interface API Reference.
Components that consume structured data require CDF. These components include:
Menu
Copyright © TIBCO Software Inc. All Rights Reserved.
47
Menu
Tree
Select and Combo
Matrix
Charting
CDF Schema
The CDF schema is described by the following XSD:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element type="cdfrecord" name="record"
maxOccurs="unbounded" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="jsxid">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="jsxroot"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="cdfrecord">
<xsd:sequence>
<xsd:element type="cdfrecord" name="record"
maxOccurs="unbounded" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="jsxtip" type="xsd:string"/>
<xsd:attribute name="jsxvalue" type="xsd:string"/>
<xsd:attribute name="jsxdivider" type="xsd:string"/>
<xsd:attribute name="jsxtext" type="xsd:string"/>
<xsd:attribute name="jsxstyle" type="xsd:string"/>
<xsd:attribute name="jsxkeycode" type="xsd:string"/>
<xsd:attribute name="jsxunselectable" type="xsd:string"/>
<xsd:attribute name="jsxexecute" type="xsd:string"/>
<xsd:attribute name="jsxgroupname" type="xsd:string"/>
<xsd:attribute name="jsximg" type="xsd:string"/>
<xsd:attribute name="jsxselected" type="xsd:string"/>
<xsd:attribute name="jsxid" use="required" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
The CDF schema is an open schema that can be extended using custom entities and attributes.
In the following example, the jsxtext and jsxid attributes are system attributes with special
meaning. The jsxid attribute is required for a record in the CDF. This attribute acts as a key and
should be a unique value. The number and name attributes are custom, developer-defined
attributes.
<?xml version="1.0"?>
<data name="" number="" jsxid="jsxroot">
<record name="a" number="0" jsxid="null" jsxtext="Select a
State"/>
<record name="b" number="1" jsxid="AL" jsxtext="ALABAMA"/>
<record name="c" number="2" jsxid="AK" jsxtext="ALASKA"/>
<record name="d" number="3" jsxid="AZ" jsxtext="ARIZONA"/>
<record name="e" number="4" jsxid="AR" jsxtext="ARKANSAS"/>
<record name="f" number="5" jsxid="CA" jsxtext="CALIFORNIA"/>
<record name="g" number="6" jsxid="CO" jsxtext="COLORADO"/>
<record name="h" number="7" jsxid="CT" jsxtext="CONNECTICUT"/>
<record name="i" number="8" jsxid="DE" jsxtext="DELAWARE"/>
...
<record name="Y" number="50" jsxid="WI" jsxtext="WISCONSIN"/>
<record name="Z" number="51" jsxid="WY" jsxtext="WYOMING"/>
</data>
Depending on the component, a record can represent a table row, a node in a tree, a menu item,
and so on. Although the record element isn't required, at least one record is required for a CDF
component to display data.
Hierarchical structures, such as submenus, can also be defined by nesting records within
records. Entities by any other name, such as a node named lookup as opposed to record, are not
displayed on-screen, but can be useful for organizing information within the CDF model. If
additional hierarchies are described by nesting records, the view displays these where relevant.
Currently, the Matrix, Menu, and Tree controls visualize hierarchical relationships, while the
other controls flatten these out. Consider the following CDF structures and their visual
representations as defined by the Menu class.
<data jsxid="jsxroot"
/>rOj
<data jsxid="jsxroot">
<record jsxid="1"
jsxtext="New"/>
<record jsxid="2"
jsxtext="Open"/>
<record jsxid="3"
jsxtext="Save"/>
</data>
<data jsxid="jsxroot">
<record jsxid="1"
jsxtext="New"/>
<record jsxid="2"
jsxtext="Open">
<record jsxid="2a"
jsxtext="Image..."/>
<record jsxid="2b"
jsxtext="Document..."
/>
</record>
<record jsxid="3"
jsxtext="Save"/>
</data>
<data jsxid="jsxroot">
<record jsxid="2"
jsxtext="Font">
<record jsxid="2a"
jsxtext="Bold"
jsxgroupname=
"font" jsxselected="1"
/>
<record jsxid="2b"
jsxtext="Underline"
jsxgroupname=
"font"/>
<record jsxid="2c"
jsxtext="Italic"
jsxgroupname=
"font"/>
</record>
<record jsxid="3"
jsxtext="Color"/>
</data>
<data jsxid="jsxroot">
<record jsxid="1a"
jsxtext="Bold"/>
<record jsxid="1b"
jsxtext="Underline"
jsxdivider="1"/>
<record jsxid="1c"
jsxtext="Italic"
jsximg="x.gif"/>
<lookups jsxid="2">
<record jsxid="3"
jsxtext="IL"/>
<record jsxid="4"
jsxtext="MA"/>
<record jsxid="5"
jsxtext="NV"/>
<record jsxid="6"
jsxtext="WI"/>
</lookups>
</data>
The jsxid attribute is required for all CDF components and must be a unique value. Support for
optional attributes varies according to component. The jsxtext and jsximg attributes are
commonly used and apply to most CDF components.
jsxdisabled Button, Checkbox, Disables the record so that a user cannot select it.
ImageButton, Menu, The record text is displayed in a grey color. Specify a
RadioButton, value of 1 to disable the record.
ToolbarButton
jsxexecute Matrix, Menu, Tree, Allows an event to run a program function when the
Table event fires. A function name or a string of JavaScript
statements can be specified. Separate multiple
statements with a semicolon (;) character. For
example, jsxexecute="var a=12;var b='5';"
jsxgroupname Matrix, Menu Adds the record to a group that can be used by
multiple CDF records or components. Records in a
group are mutually exclusive options. For example,
a menu for selecting fonts allows only one font
option to be chosen.
jsxid all Uniquely identifies the CDF record. This value can
be user-defined or automatically generated using the
getKey() method (jsx3.xml.CDF). This attribute is
required.
jsximg Matrix, Menu, Tree, References a graphic file to use as an icon. Specify
Table the file path relative to the project directory, for
example, images/icon.gif. Image position depends
on the component. For best results, use a 16x16
transparent GIF file.
jsxselected Matrix, Menu, Tree, Specifies whether the record is selected or not
Table selected by default. Specify a value of 1 to define the
record as selected.
jsxstyle Matrix, Menu, Tree, Applies a CSS style to this record. Specify any CSS
Select, Table code. For example, jsxstyle="font-weight:bold;".
jsxtext Matrix, Tree, Select, Defines the visible text for the record. For example,
Menu, Table in a menu component, the value of this attribute is
the name of the menu item as displayed in the
application.
jsxtip Matrix, Tree, Select, Defines the tooltip text to display when the cursor
Menu, Table hovers over the record. For example, jsxtip="Type
your address here".
jsxunselectable Matrix, Tree, Table Specifies whether a tree node or list item can be
selected by end users. Specify a value of 1 to prevent
the record from being selected. When the value of
this attribute is 1, the execute method for the record
cannot be called.
CDF records can also include custom attributes. Custom attribute names can be any string
except names of system attributes. To add attributes to a CDF record, call the
insertRecordProperty() method. You can also manually edit the CDF document on the file
system, or open the cached file in General Interface Builder.
If you do not explicitly set an XML Cache ID for a CDF-type control, such as matrix, menu, and
select, an ID is automatically generated by the system. The naming convention is a
concatenation of the control ID. For example, object.getId() plus an _XML suffix. An ID looks
similar to the following: _jsx_1_5_XML.
In this code example, a new XML document that represents an empty CDF document is created:
This is a good choice if a CDF component isn't required. For example, the Properties Editor
palette in General Interface Builder uses the API to create the CDF on the fly at runtime and
generate the list of available properties for the selected component in the work area.
For method details for the jsx3.xml.CDF.Document class, see the online API help in General
Interface Builder.
For method details, see the online API help in General Interface Builder.
From cache, by calling the getDocument() method (jsx3.app.Cache). This method takes
the name of the cached CDF document as input, which is system-defined by default. For
example,
myserver.getCache().getDocument("myDocument");
To avoid working with the system-defined name, use the XML Cache ID property to
specify a name for the CDF document or access the CDF document through the object.
Accessing a Node
You can access a record node within a CDF document in one of the following ways:
By calling the selectSingleNode() method (jsx3.xml.Entity) for the CDF document and
passing the appropriate XSL query. The following code example returns the node with
element name record and jsxid value of 12.
myCdfDocument.selectSingleNode(//record\[@jsxid='12']);
* From an object that implements the CDF interface, by calling the getRecordNode()
method (jsx3.xml.CDF). For example,
myObject.getRecordNode(12);
Method Summary
getKey Generates a unique identifier for use as the jsxidattribute for a CDF
record. This value persists only for the length of the browser session.
Unique values that persist across browser sessions must be generated
by the developer.
newDocument A factory method for creating a new CDF document containing the
following XML: <data jsxid="jsxroot"/>
adoptRecord Transfers a CDF record between components. The record must have a
unique jsxidvalue to be transferred. If no CDF document exists for
the adopting parent, a document is created and added to the cache. If
successful, this method returns a jsx3.xml.Entity instance, which is
an object handle to the transferred record. The view for the record is
automatically updated.
deleteRecordProperty Deletes a specific property from a CDF record. The record must have
a unique jsxid value. Do not call this method to delete the jsxid
property.
getRecord Returns a JavaScript object that is a clone of the specified CDF record.
Any updates to this clone doesn't affect the original record unless you
call object.insertRecord() and pass the modified clone as the input
parameter.
insertRecord Inserts a new record into the CDF document for the component. If no
CDF document exists for the component, a document is created and
added to the cache. If a record with the same jsxid value already
exists, the existing record is updated.
insertRecordBefore Creates a new CDF record and inserts it into the CDF data source of
this object, before the record identified by the parameter,
strSiblingRecordId.
insertRecordNode Inserts a new record node into the control's XML-formatted data
source. If no CDF document exists for the component, a document is
created and added to the cache. If a record with the same jsxid value
already exists, the existing record is updated. This function is for
inserting records as XML node entities rather than JavaScript objects.
insertRecordProperty Inserts a new CDF attribute and corresponding value for the specified
CDF record. The attribute can be one of the system attributes defined
in CDF System Attributes or a custom attribute. Updating the view
for the record is optional.
Adding Records
Use the insertRecord() and insertRecordNode() methods to add records to a CDF document.
The two methods are functionally equivalent, but insertRecord() takes a JavaScript object as
input, while insertRecordNode() takes an XML entity. With insertRecord(), you specify the
jsxid attribute, along with any other CDF attributes for the record, as properties of the object.
insertRecord Example
The following sample JavaScript code illustrates how to add records to a Matrix component
using insertRecord() :
In this example, the new CDF record object is objRecord. The first property defined for this
object, jsxid, is a required system attribute that must be unique. The getKey() method is used
to generate a unique jsxid value for this record. Other properties, Date, Security, Open, and
High, become custom attributes of the CDF record. Values for these properties are provided by
components in the application.
In addition to a JavaScript object, the insertRecord() call takes two parameters — the numeric
identifier (jsxidvalue of a parent object) and an optional Boolean parameter for a redraw
operation. When null is specified for the second parameter, as in this example, the record is
added to the root element of the CDF document.
Since this example adds a single record, the overhead associated with redrawing the record is
insignificant. When adding multiple records, such as in a loop, consider passing a value of false
for this parameter and repainting the entire component after all records are added. For details,
see Redrawing and Repainting Records.
Updating Records
When you add a record that has the same jsxid value as an existing record in the CDF
document, the existing record is replaced. Make sure jsxid values are unique before adding
records. For details, see Generating Unique Identifiers.
You can use the insertRecordProperty() method to add attributes to an existing record in a
CDF document. Specify the jsxidvalue of the record to modify, along with the attribute name
and attribute value. The following sample illustrates how to add an attribute to an existing
record within an ID (jsxid) of 58:
objList.insertRecordProperty("58","mypropname","mypropvalue");
The process of removing attributes is similar. Using deleteRecordProperty(), specify the jsxid
value of the record to modify and the name of the attribute to remove. Although not specifically
restricted by the API, do not remove the jsxid attribute from a record. The following sample
JavaScript code illustrates how to remove an attribute from an existing record:
objList.deleteRecordProperty("11","jsximg");
In both of the preceding examples, the record is automatically refreshed to reflect the change in
the application. You could also pass a value of false for the optional bRedraw parameter to
prevent the redraw operation. For details on optimizing redraw and repaint operations, see
Redrawing and Repainting Records.
Deleting Records
Use the deleteRecord() method to delete a record from a CDF document. This method returns
an object handle to the XML entity instance that was removed. The following sample JavaScript
code illustrates how to delete an existing record:
If the content of the CDF document is built programmatically by your application, you can use
the jsx3.xml.CDF.getKey() method to generate a unique value for the jsxid attribute. The
generated value is guaranteed unique across multiple components for the browser session. For
an example, see Adding Records.
If the content of the CDF document is built outside of your application, you can use any key
value in an XML attribute as the jsxidvalue. If no key value exists in the original XML when
transforming the XML into CDF, use the XPath generate-id function to generate a unique value.
In general, repainting the component affects all records and is resource-intensive. Repainting
Copyright © TIBCO Software Inc. All Rights Reserved.
60
In general, repainting the component affects all records and is resource-intensive. Repainting
the component should be avoided unless a sizable number of records are modified. For
example, if many records are added in an iterative manner, it can be more efficient to repaint
the component once, after all additions have been made. To repaint a component, call the
repaint() method for the specific component.
CDF methods, with the exception of the adoptRecord()}}method, accept an optional Boolean
parameter that signifies whether the on-screen view should be immediately updated to
reflect the update to the in-memory model. A value of {{true , which is the default value,
redraws the record after modification. For the adoptRecord() method, both controls (the former
and new parent) are redrawn.
Counting Records
You can count the number of records in a CDF document by querying for all records and
calling the getLength() method on the object that is returned. The following sample illustrates
this for the List control.
First, call the getXML() method for the object, then the selectNodes() method (jsx3.xml.Entity)
for the XML entity, passing the path for the nodes to select. This method returns a handle to the
jsx3.util.List object containing all record nodes in the CDF document. Calling the
getLength() method on this object returns the number of CDF records.
The flexible CDF schema feature allows these same classes to consume datasources that do not
strictly follow CDF. This feature is particularly useful for consuming pre-existing XML
datasources that were created without knowledge of CDF.
The core CDF schema elements and attributes data, record and jsxid can be renamed to
anything
A single data source can drive multiple CDF controls, each with its own view of the data
Each CDF control has a schema property of type jsx3.xml.CDFSchema. The value of this property
defines how the control views its CDF datasource. If the schema property is not set then the
control uses the default CDF schema.
Each CDF control first queries its schema for the name of the text attribute and then queries its
datasource for that attribute of a record. For example, the implementation of jsx3.gui.Tree
includes expressions such as
this.getRecordNode(id).getAttribute(this.getSchema().getProp("text"))
<data jsxid="jsxroot">
<record jsxid="1" label="One"/>
...
</data>
You can control flexible CDF schema from within General Interface Builder. To do so,
1. Open or create a component with a CDF control in it, such as Matrix, Tree or Menu.
2. Find the CDF Schema component in the Component Libraries palette and drag it onto
the CDF control. It may be easier to drag it onto the corresponding node in the
Component Hierarchy palette.
3. Modify the properties of the schema object in the Properties Editor.
The Properties Editor contains an editable property for each attribute in the default CDF
schema. In general, the default value of property abc is jsxabc. CDFSchema also has a property
called record. This property allows you to change the element name of the records in the
datasource. You can choose another name, such as item or you can use set it to * to indicate
than any XML element should be interpreted as a data record.
<items id="jsxroot">
<item id="1" label="One"/>
<thing id="2" label="Two"/>
<object id="3" label="Three"/>
...
</items>
Using the same datasource for two different controls is simply a matter of defining a unique
CDF schema for each control.
Click to download a sample project that uses the flexible CDF schema feature: GI-702.zip.
The CIF format uses several new namespaces, the root of which is
http://xsd.tns.tibco.com/gi/cif/2006. The new format is 100% compatible with the v3.0
serialization format. An XSLT is used for the conversion between CIF and v3.0 formats.
Currently, General Interface Builder can read but not save CIF files. Any edits made to a CIF
file are saved in the old serialization format.
<component xmlns="http://xsd.tns.tibco.com/gi/cif/2006"
*classpath*="jsx3.gui"
xmlns:e="http://xsd.tns.tibco.com/gi/cif/2006/events"
xmlns:\d="http://xsd.tns.tibco.com/gi/cif/2006/v3.2/dynamics"
xmlns:\p="http://xsd.tns.tibco.com/gi/cif/2006/property"
xmlns:\pe="http://xsd.tns.tibco.com/gi/cif/2006/property.eval"
xmlns:x="http://xsd.tns.tibco.com/gi/cif/2006/xslparameters"
xmlns:v="http://xsd.tns.tibco.com/gi/cif/2006/view"
xmlns:id="http://xsd.tns.tibco.com/gi/cif/2006/inlinedata"
xmlns:u="http://xsd.tns.tibco.com/gi/cif/2006/userdefined"
xmlns:ue="http://xsd.tns.tibco.com/gi/cif/2006/userdefined.eval"
>
<id:\data href="AX1"
handler-for="jsx3.lang.Serializeable.Array">
<object>
<item>38</item>
<item>*</item>
<item>26</item>
</object>
</id:\data>
</LayoutGrid>
p:\padding="8">
<Select p:name="sel1" id:xml="HRTL129Q">
<id:\data href="HRTL129Q">
<![CDATA[
<data jsxid="jsxroot">
<record jsxid="TIBX" jsxtext="TIBCO"/>
<record jsxid="MSFT" jsxtext="Microsoft"/>
<record jsxid="YHOO" jsxtext="Yahoo!"/>
<record jsxid="EBAY" jsxtext="Ebay"/>
<record jsxid="GOOG" jsxtext="Google"/>
<record jsxid="IBM" jsxtext="IBM"/>
</data>
]]>
</id:\data>
</Select>
</Block>
</Splitter>
</Dialog>
</component>
CIF Definitions
Node Name Namespace Description
xmlns:u=
"http://xsd.tns.tibco.com/
gi/cif/2006/userdefined"
xmlns:ue=
"http://xsd.tns.tibco.com/
gi/cif/2006/userdefined.eval"
In much the same way that WSDL (an XML document format) defines SOAP transactions,
General Interface employs a tree-like definition language of its own referred to as the Common
Exchange Format (CXF). Using a common format for defining transactions allows General
Interface to communicate with a myriad of systems without being tied to a particular interface
definition. CXF documents are created at design time by the XML Mapping Utility using any
number of formats as a starting point for creating the definition. Supported formats include
WSDL, schema, XML, and XHTML. CXF documents are referred to as mapping rules files or
rules files throughout the documentation.
Once parsed by the XML Mapping Utility, XML documents are persisted in CXF format. A CXF
Copyright © TIBCO Software Inc. All Rights Reserved.
68
Once parsed by the XML Mapping Utility, XML documents are persisted in CXF format. A CXF
rules document can then be mapped to application objects, such as CDF documents, text boxes,
and nodes in the Local Data Cache palette.
Regardless of whether WSDL, Schema, or XML is used, all input formats result in the same
transactional format. In practice, this means that the interactions with a SOAP service can be
defined by using WSDL or a sample SOAP message, such as an Envelope, as a starting point.
Ultimately, the source type (WSDL, Schema, or XML) used to create a CXF rules document is
irrelevant once the CXF document has been created, as all formats are persisted using CXF.
Another way to think about CXF is to think of it as an interpretive language that is able to
interface between the XML document formats used by a given web service and the native CDF
and JavaScript formats used by General Interface. Just as it is important to be versed in CDF in
order to know how data is used within General Interface, an understanding of CXF provides
insight into how data is shared between General Interface and data services. While CDF
provides the format for data while it is within the control of General Interface, CXF provides
the bridge to convert this information to the format required by the given web service.
</record>
</record>
</data>
The following table provides attribute definitions. Each of these attributes exists in one or more
rule types, which are described in CXF Rule Types.
Attribute Description
datatype Data type for the node. For example, xsd:string. This is relevant to RPC
Encoded WSDL inputs. When the final message is generated and sent to the
remote service, this value is used to specify the encoding for a node in the
message.
endpoint URL for the remote service to contact. Although WSDL binds the endpoint
to the service (which can encapsulate one or more operations), CXF binds
the endpoint to each individual operation.
groupref If equal to 1, the node is flagged as structural, which means that it isn't part
of the generated message. The node appears in the rules tree as an
organizing element but isn't generated and sent with the request, essentially
removing the abstract node and appending its descendant structures to the
structural node's immediate parent.
jsxid System ID for the record. This is assigned by the system and is unique for
each node in the CXF document. This attribute is only relevant at design
time.
jsxtext System text for the record. More importantly, this is the node name (for
attributes and entities) in the message.
name Applies to records in the CXF that define mappings, HTTP headers, and
restrictions. In the case of mappings, this is the map type (i.e., DOM, Script,
CDF Document, and so on). For HTTP headers, this is the header name. For
restrictions, this is the type of the restriction (enumeration, nillable, pattern,
and so on).
onbeforesend JavaScript code to execute immediately before sending the request message.
opname The name of the operation. This value is unique among all other operation
nodes in the CXF document. In the case of a CXF that was created without a
WSDL, there is only one operation for the CXF named jsxtransaction.
path The node path to find this item in the original source Schema used to create
the CXF. This attribute is only used by WSDL and Schema input types and
is only relevant at design time.
ref If equal to 1, this node will be flagged by the XML Mapping Utility as a
referential node, pointing to a group or attributeGroupelement in the
source WSDL/Schema. This attribute is only relevant at design time and is
used to convert the indirection used by Schema to the concrete structures
used by CXF.
repeat If this attribute exists, its value will be evaluated as JavaScript within the
context of the jsx3.net.Service instance that is processing the given CXF. If
the result evaluates to true, the given branch in the CXF will be processed
again. This only applies to XML documents generated on the client. This
value is ignored when processing a service response.
simple If equal to 1, the data type for this node is one of the simple types defined by
Schema (http://www.w3.org/2001/XMLSchema-instance).
soaprpcns If an RPC Encoded message, the namespace for the remote procedure (the
message).
src URL for the source document that is serving as the pattern master for
generating the CXF. The pattern master is the input document that was used
by the XML Mapping Utility to create the CXF (typically a WSDL). This
attribute is only relevant at design time.
stubsrc URL for the base shell document. Also used for inbound messages (response
nodes) when running in static mode.
stubpath The XSL Query for the node in the base shell document ( stubsrc) to which
the generated document will be appended.
tns If this value exists on a Rule node contained by an Input node, the Rule will
be qualified and the value of the tnswill be appended to the root node in the
response document. If it exists on a rule contained by the output or fault
nodes, it defines a qualified namespace, meaning that it isn't enough for the
node names to match for the rule to be applied; rather, the node's
namespace must also match.
ttns Represents the target namespace for the data type and applies to
rpc-encoded messages. For example, if the target namespace tns is abc.com
and ttns is def.com, you would see something similar to the following in a
message:
type The type of rule. For example, A, C, E, and so on. The most common type is
E, which represents a mapping rule to an Entity node type in the CXF.
value Applies to records in the CXF that define mappings, HTTP headers, and
restrictions. In the case of mappings, this is the map path/value. For HTTP
headers, this is the header value. For restrictions, this is the value of the
restriction.
WSDL jsxid, jsxtext, This is the top-level node in a CXF document that
//record[@type='W'] type, src, type resulted from a WSDL input. The most relevant
attribute is src, which describes the location of
the original WSDL in case the CXF document is
in-edit and still needs a back-reference to the
original WSDL.
Transaction jsxid, jsxtext, This is the top-level node in a CXF that resulted
//record[@type='T'] type, endpoint, from a non-WSDL input. It is equivalent to the
method, opname third-level Operation node that results from a
WSDL input, except that it does not define a path.
Instead, its child input and output rules define
the path to their respective source documents.
Rule jsxid, jsxtext, Rule nodes define the mappings and restrictions
//record[@type='A' type, datatype, and are used to either generate a node in the
or @type='C' or groupref, path, input message or process a node in the output.
@type='D' or ref, repeat, Note the following definitions: A: attribute node
@type='E'] simple,tns,ttns E: entity node D: CDATA node C: complex node
(contains E, C, D, or A nodes)
General Interface applications can send and receive any type of text data sent using HTTP/S.
The jsx3.net.Request class is used for this exchange, providing a generic transport mechanism
for text content, regardless of format. Data that is in XML format can be stored in the local data
cache for repeated use by various objects within the application.
Sending Data
You can send data from an application using the methods: GET or POST. Depending upon the
capabilities of the server being called, other methods like DELETE, PUT, and HEAD may also
be called.
For a POST interaction, pass the string content as the only parameter to the send() method. For
GET, use another content mechanism, such as an overloaded URL, as in this example:
function onResponse(objEvent) {
alert(req.getResponseText());
};
req.subscribe(jsx3.net.Request.EVENT_ON_RESPONSE,onResponse);
//send
req.send();
General Interface applications perform best when they use asynchronous data access. However,
there are times when you might want to synchronously access data. The above call made
synchronously is shown in the following example:
//send
req.send();
alert(req.getResponseText());
Receiving Data
The process for receiving data depends on whether the data is valid XML or another format.
reqSocket.send();
To save the response document for repeated access, use the setDocument function to load it into
the local data cache as follows:
myApp.getCache().setDocument("MyCacheDocument", repXML);
Also note that the Request class has different methods for accessing data. The example shown
above is the simplest of all data calls: a synchronous HTTP GET. In fact, requesting and caching
data in this manner can be done with only one API call, openDocument as shown in the following
example:
The Cache class has different methods for accessing data more efficiently than the
{{openDocument}} method just described. For example, the method
{{getOrOpenDocument}} will first check the cache for the document before attempting
to load it.
If the document is large or the server will respond with a known latency, fetch the
document asynchronously, using {{getOrOpenAsync}}. This method returns the
corresponding document synchronously if it already exists in the cache. If the
document does not exist in the cache, then it is loaded asynchronously and the method
returns a placeholder document. The namespace URI of this placeholder document is
{{jsx3.xml.Cache.XSDNS}} and its root node name is {{loading}}.
Because the cache stores this placeholder document until the document finishes
If the {{getResponseXML}} call fails but the content is valid XML, you can still
parse it by calling the {{getResponseText()}} method and passing the XML string into
a {{jsx3.xml.Document}} instance as follows:{code:lang=javascript}var objXML = new
jsx3.xml.Document();
objXML.loadXML(XML_string);
For more details on the getResponseText() method, see Receiving Non-XML Data.
window.alert(strText);
Non-XML data is useful in many situations. For example, non-XML data can be displayed in
the application by setting it as the text property of a jsx3.gui.Block object, or it can be
reformatted into CDF for use by a Matrix component. Also, if the data is converted to XML, it
can be stored in the local data cache to facilitate data access and management.
Caching Data
Each General Interface application maintains a separate local data cache. If two applications are
embedded on a single web page, each has its own cache. This local data cache should not be
confused with the browser file cache for temporary Internet files. The General Interface local
data cache is an in-memory, JavaScript hash of parsed XML documents that disappears when
the browser window is closed. Any XML document, including XML, CDF, and XSL files, can be
stored in the local data cache.
Controls that display XML data interface with the local data cache by way of the
jsx3.xml.Cacheable interface. This class provides methods that link a GUI object and the local
data cache data it needs. The GUI object never refers to the data by reference. Only the local
data cache references the XML document object, facilitating improved dereferencing and object
cleanup.
The Share Resources property is an important property of GUI classes that extend Cacheable
(Menu, Tree, Matrix, and so on). When the Share Resources property is set to false (default
setting) and the GUI object is removed from the General Interface DOM, the associated XML
and XSL documents are also removed from the local data cache. Set this property to true if two
GUI objects refer to the same document or if the document should remain in the local data
cache after the GUI object is removed.
app1.getCache().method_name
You can cache any XML, CDF, or XSL document using the openDocument() method. The
openDocument() method allows you to specify the URL of a file to load and parses the file into a
jsx3.xml.Document instance. To cache the document, provide a second parameter to use as the
Copyright © TIBCO Software Inc. All Rights Reserved.
80
jsx3.xml.Document instance. To cache the document, provide a second parameter to use as the
cache ID as follows:
app1.getCache().openDocument
("http://ibiblio.org/bosak/coriolan.xml","someCacheId");
To explicitly load a file into cache independently of the openDocument() method, use the
setDocument() method.
app1.getCache().getDocument("myDocument");
When a document is requested from the local data cache and the document isn't found, the
General Interface system queries the shared global cache. For example, if the local data cache
doesn't have a document named abc, each of the following calls is equivalent, assuming that the
application namespace is app1:
or
In General Interface Builder, project files can be configured to load automatically when the
application loads. To manually specify which project files are automatically loaded into cache,
right-click the file name in the Project Files palette and select Auto Load. Any type of project
file except a GUI component and a mapping rule can be configured to automatically load. For
more information on Auto Load options, see File Profile Dialog.
When you're working in General Interface Builder, XML and XSL project files can be manually
loaded or reloaded into the local data cache by doing the following:
In the Project Files palette, right-click the file name and select Load/Reload.
In the work area, right-click the associated tab and select Save and Reload after
modifying an XML or XSL document.
To view the contents of the local data cache in General Interface Builder, choose Palettes > Local
Copyright © TIBCO Software Inc. All Rights Reserved.
81
To view the contents of the local data cache in General Interface Builder, choose Palettes > Local
Data Cache.
For information on General Interface document formats, see Custom Document Formats.
CXF documents can also be used for internal transformations and mappings, making them
useful even when a remote service isn't involved. The following figure depicts how CXF can be
used to process and transform the messages exchanged with a remote service. The next figure
shows how CXF can be used for internal mappings and transformations.
Because CXF is used to define how information is processed, CXF documents are commonly
referred to as rules files. The XML Mapping Utility is the design-time tool that creates a rules
file, and the jsx3.net.Service class is the runtime engine that executes a rules file. If the rules
file specifies that a remote service is involved, the jsx3.net.Service class manages all
communications, using its own instance of jsx3.net.Request for the HTTP communications.
The XML Mapping Utility prompts you to select one or more source documents to use as the
starting point for the mapping rules file. After the source documents are parsed, the XML
Mapping Utility user interface is displayed.
Copyright © TIBCO Software Inc. All Rights Reserved.
84
For definitions of fields in the XML Mapping Utility, see XML Mapping Utility.
For more information on toolbar buttons, see XML Mapping Utility Toolbar.
The rules in the rules file can be edited independently of the source document. After the initial
parse, you can add rules to and remove rules from the file as needed. For example, unmapped
rules can be removed to minimize the size of the rules file. Additional rules can be defined to
customize the service interaction or account for changes to the service over time.
Complex A rule that maps to an element node and which has descendant
Type element, attribute, or CDATA rules.
Data Type The XSD data type of the selected rule, such as string, boolean,
decimal, and so on.
Restriction A rule that has a restriction assigned to it. Restrictions are used
to validate and restrict user input. See Restrictions.
(1), (0 - 1), Inclusive minimum and maximum number of times this rule
(1-unbounded) can appear in the XML message.
Test Invokes a tool to test the mappings. For more information, see Testing Outbound
and Inbound Messages.
Map Automatically maps the selected rules to GUI components and CDF elements. For
more information, see Automatically Generating GUI Components and Input Mappings
and Mapping Response Data to CDF GUI Components.
Detach Removes mappings, restrictions, or HTTP headers for the selected rules.
Delete Deletes the selected rules or all unselected sibling rules.
Generate Generates the JavaScript code that will be needed to execute the rules file in the
running application. See Calling a Data Service.
Copyright © TIBCO Software Inc. All Rights Reserved.
86
For more information on toolbar buttons, see Rules Tree Panel Toolbar.
Original Schema Source Displays the read-only Schema source for the selected rule. This
binding can be updated by modifying the Source Path field in the Rule Profile panel.
Maintaining this binding is only important at design time, particularly if the rule node
may need to be reparsed from source.
Rule Node Profile Displays profile information for the selected rule, such as target
namespace, data type, and rule name. Some of these fields are editable. For more
information on these fields and how to modify profiles, see Working in the Rule Profile
Panel and Rule Profile Panel.
Settings Panel
The Settings panel, to the right of the Rules Tree panel, displays fields pertinent to the type of
rule selected in the rules tree. If no rule is selected in the rules tree or if multiple rules are
selected, the Settings panel is blank. You can use the Settings panel to define how the rule is
processed, such as add restrictions, mappings, JavaScript code, and so on.
For more information about fields in the Settings panel, see Settings Panel. For more
information on using the Settings panel, see Working in the Settings Panel.
For additional information and API documentation, hover the mouse over the question mark
icon and the APIs icon in the Settings panel.
APIs
CDFCONTEXT (Direction: input, output)*---CDF record node being acted upon
CDFRECORDS (Direction: input, output)* - CDF records collection being iterated
RULENODE (Direction: input, output)* - Current node in the rules tree being processed
MESSAGENODE (Direction: input, output)* - Node in the message being processed
OBJECTTYPE (Direction: input, output)* - Deprecated. Now evaluates to 'Script'
OBJECTNAME (Direction: input, output)* - Deprecated. Will always evaluate to what
FILTER once evaluated to--namely the Script being evaluated
FILTER (Direction: input, output)* - Deprecated. Do not use.
setValue(strValue) (Direction: input)* - Equivalent to MESSAGENODE.setValue(strValue)
setCDFContext(strXSLQuery) (Direction: input)* - Valid selection query to update
CDFCONTEXT. Must return an object reference to a CDF Record node.
setCDFRecords(strXSLQuery) (Direction: input)* - Updates record collection to be
iterated. Must return a valid jsx3.util.Collection instance containing one or more CDF
record nodes.
disableNamedRule(strNodeName) (Direction: input)* - Disables the named child rule, so
that it does not execute until enableNamedRule is called.
enableNamedRule(strNodeName) (Direction: input)* - Re-enables the named child rule.
disableReferencedRule(objRuleChild) (Direction: input)* - Disables the child rule, so
that it does not execute until enableReferencedRule is called.
enableReferencedRule(objRuleChild) (Direction: input)* - Re-enables the child rule.
*Contextual variables listed as inputs are available when creating input messages. Outputs are
available when processing output messages.
Mapper Log
The Mapper Log displays information about the outcome of parsing the starting source
document(s). Different log levels can be selected by clicking on the Adjust Log Level button
in the Mapper Log panel. Possible levels, from most detailed to least detailed, include Trace,
Debug, Info, Warn, Error, and Fatal. The default level is Info and the XML Mapping Utility
resets to this value when closed.
The Mapper Log can also be used to view the message exchange when using the Test Interface
Tool.
Mapping rules are individual rules within the mapping rules file. There are many types of
mapping rules, each of which defines a particular aspect of the mapping process. For example,
rules that descend from the output rule define how to process (read) a document in the local
cache or returned from a remote service, while mapping rules that descend from an input rule
define how to create (write) a node in an XML document.
The first step in mapping GUI components or CDF documents to a mapping rule is to create a
mapping rules file.
The XML Mapping Utility accepts many types of source document formats to begin defining
the mapping rules file, including WSDL, XML, XSD, XHTML, JSON, and well-formed HTML.
Data in any of these formats can be parsed and used as a starting point for defining mappings.
When the mapping rule will be used to not only read and write XML, but also communicate
with a remote service, the HTTP methods, PUT, GET, POST, and DELETE are supported.
This section uses the General Interface WSDL Mapping 2 sample located in
workspace/JSXAPPS/samples/WSDL_Mapping_2. By default, this sample runs in Static
Mode, rendering the results of a sample message on screen. To run against the
Xignite web service in Live Mode, register for a license key at
http://www.xignite.com/xhistorical.asmx?op=xRegister. Then set the project to Live
Mode on the Deployment panel of the Project Settings dialog (Project > Project
Settings > Deployment) and reload your browser.
WSDL Files
Select WSDL if your source document is a WSDL that defines a Doc Literal or RPC Encoded
SOAP service. Specify the location of the WSDL file in the URL field. See Specifying Paths in the
XML Mapping Utility.
Specify the location of source document(s) in the URL fields. See Specifying Paths in the XML
Mapping Utility.
JSON Files
Select JSON if your source document is in JavaScript Object Notation data interchange format.
Specify the location of the source document in the URL field. See Specifying Paths in the XML
Mapping Utility.
If you need to resolve a path to a source document outside of your project, use an absolute
resolver, such as jsxuser:/// and jsxapp:///.
jsxuser:///... Resolves relative to the parent of the JSXAPPS directory, which is the
workspace. When General Interface Builder is running, this URI resolves relative to the
workspace directory.
jsxapp://app/... If the Server instance corresponding to the host portion of the URI is
loaded into memory, the URI is resolved relative to the application base directory (
jsxappbase).
1. Copy the file(s) to be used as the starting point for the mapping rules file to your
project---a WSDL file, XML/HTML/Schema files, or a JSON file. This example uses
Historicals.wsdl in workspace/JSXAPPS/samples/WSDL_Mapping_2/wsdl.
2. Open the XML Mapping Utility using one of these methods:
Select File > New > Mapping Rule.
Choose Tools > XML Mapping Utility.
3. Select the file type you are using as the starting point for the mapping rules file: WSDL,
XML/XHTML/Schema, or JSON. See Choosing the File for the Rules File Starting Point.
4. Enter a URL and parse the document:
a. Type the URL for a source document(s) to be used as the starting point for the
rules file or click the Browse button to locate the file. See Specifying Paths in the
XML Mapping Utility.
For example, if the Historicals.wsdl is saved in a wsdl folder in your current
project, type wsdl/Historicals.wsdl as the starting point for the rules file.
b. Click the Parse Document button to generate the mapping rules file.
After you click Parse Document, a new rules file is created. The XML Mapping
Utility looks similar to the following:
5. Modify the mapping rules file as desired. For example, remove any extraneous rules as
Copyright © TIBCO Software Inc. All Rights Reserved.
91
5. Modify the mapping rules file as desired. For example, remove any extraneous rules as
follows:
a. Select a rule or rules in the rules tree. Use Shift+click or Ctrl+click to select
multiple rules.
b. Choose Delete > Delete Selected Rules to delete the rules you've selected. Or
choose Delete > Unselected Sibling Rules to delete the unselected rules.
For example, select GetHistoricalQuotes (not the singular GetHistoricalQuote) in
the Rules Tree panel and choose Delete > Unselected Sibling Rules from the
Rules Tree panel menu to remove the other operation rules that were defined by
the source WSDL. This helps to reduce the size of your mapping rules file so that
it only defines those operations that will be run.
For more information, see Modifying Mapping Rules Files.
6. Save the rules file with the .xml extension.
Choose menu commands in the Rules Tree panel. See Working in the Rules Tree Panel.
Set rule profile values in the Rule Profile panel. See Working in the Rule Profile Panel.
Set fields in the Settings panel. See Working in the Settings Panel.
Use drag-and-drop to map application GUI components to rules in the Rules Tree panel.
See Manually Mapping GUI Components and Input Mappings.
In these situations, the tools in the Rules Tree panel help you manage the structure and
relationship for each rule, including reordering rules using drag-and-drop, adding new rules,
cloning existing rules, and removing existing rules.
Reordering Rules
Because the rules tree is an execution tree, the order of the rules defines the order of execution.
More specifically, the rules are traversed by depth and then breadth.
To reorder a rule, simply drag and drop it to a new location in the tree.
Adding Rules
To add a rule to the rules file, right-click a rule in the rules tree and choose Add New Rule.
Then choose a command from the submenu, such as Element, Attribute, or CDATA. Once
you've created a rule, you can modify the profile in the Rule Profile panel. See Working in the
Rule Profile Panel.
Cloning Rules
It's also possible to clone any node in the rules tree, including its descendant content. To clone a
rule, right-click a rule in the rules tree and choose Clone.
Deleting Rules
If you only need to work with some of the rules that were automatically generated when the
source document(s) were parsed, you can delete the unnecessary rules to reduce the clutter in
the Rules Tree panel. Reducing the rules in the tree also optimizes the rules file for the web as it
only contains necessary rules. This optimized rules file is a key advantage to using the XML
Mapping Utility instead of the more verbose WSDL file. Note that deleting rules doesn't affect
the source document.
To delete a rule and all of its children from the rules tree, select the rule(s) you want to delete
and choose Delete > Selected Rules.
To delete all unselected sibling rules from the rules tree, select the rule(s) you don't want to
delete and choose Delete > Unselected Sibling Rules.
Regenerating Rules
The ability to reparse rules is helpful if you've deleted a rule by mistake or you want to remove
the rule settings. Often, minor changes to the source WSDL can be handled by downloading a
copy of the updated WSDL and replacing the local copy that you used to create the original
rules file. Then, right-click the parent rule in the rules tree. Choose Reparse to re-parse from
that rule down. When the Reparse Selected Branch dialog displays, click the Reparse button to
reparse the rule. The rule is returned to its original state and all mappings are lost.
In some situations the reparse will fail. If that occurs, select the rule in the rules tree, choose the
Rule Node Profile radio button, and write your own XPath in the Source Path field to recreate
the binding between the rule in the rules tree and the Schema definition in the source document
from which it originates.
For example, if you parse the default WSDL Address.wsdl, the ReturnCityState element maps to
the Schema node at this address:
//jsx3:schema[@targetNamespace='http://ws.cdyne.com/']//jsx3:element[@name='ReturnCityState']
The above address is brittle, because if an additional element is added to the Schema, it can
corrupt the absolute addressing. In such a case, simply edit the XPath to use an XPath address
that is less brittle. For example,
//jsx3:element[@name='ReturnCityState']
When authoring your own XPath for a WSDL document, use the jsx1 prefix to point
to any node in the source document belonging to the namespace,
http://schemas.xmlsoap.org/wsdl/. Use jsx3 to resolve to the namespace,
http://www.w3.org/2001/XMLSchema. For all other source document types
(XHTML, Schema, XML, etc), the prefix is an incremented value (jsx1, jsx2, jsx3, etc)
that reflects the order in which the namespace was first declared in the source
document.
Adding Mappings
Rules that descend from input or output rules can be mapped to GUI components, as well as to
CDF documents, records, and attributes. For example, you can map user input in a text field to
a rule in your rules file and then send this data to a web service in the outgoing message.
Incoming data from the web service can then be mapped to a CDF document, allowing the
server's response to be displayed in the user interface.
Drag and drop a GUI component from the Component Hierarchy palette to a rule in the
Rules Tree panel. See Mapping GUI Components to Mapping Rules.
Select a rule and create a mapping using the Map menu. See Mapping Response Data to
CDF GUI Components.
Select a rule and set the mapping in the Mapping table in the Settings panel. See Adding
a Mapping to the Mappings Table.
To remove mappings from a rule, select one or more rules that have a mapping and choose
Detach > Mappings. Rules that have mappings are indicated with a Mapping icon .
Mappings are displayed in the Settings panel on the right.
To remove restrictions from a rule, select one or more rules that have restrictions and choose
Detach > Restrictions. Rules that only have maxoccur and minoccur restrictions don't have an
icon in the rules tree. Rules that have additional restrictions are indicated with a Restriction
icon . Restrictions are displayed in the Settings panel on the right.
To remove HTTP headers from a rule, select an operation rule that has HTTP headers and
choose Detach > Headers. HTTP headers are displayed in the Settings panel on the right.
1. Select the rule you want to modify in the Rules Tree panel.
2. Select the Rule Node Profile radio button below the Rules Tree panel.
3. Click in the Value field next to the name you want to modify.
4. Type in a value.
5. Generate a test message to test the impact of changes to the rule profile. To generate a
test message, right-click an input or output rule in the Rules Tree panel and choose
Generate Sample Message.
The Settings panel only displays fields pertinent to the selected rule. These four types of rules
display fields in the Settings panel:
When you use the SCRIPT method, the XML Mapping Utility uses a SCRIPT tag for the transport
instead of the standard XMLHTTP control.
With the SCRIPT method, you can set an additional field to specify that the service uses JSONP
(JSON with padding). When this field is set, the service class appends an additional parameter
to the URL in the form
callback={method}
This allows for flexibility when using JSON Services that are also available as JSONP
Copyright © TIBCO Software Inc. All Rights Reserved.
96
This allows for flexibility when using JSON Services that are also available as JSONP
Services---you can use the same endpoint URL, but implement different behaviors. If the given
JSONP Service expects the name of the callback parameter to be something different than
callback, use the runtime API call, setJSONP, to pass the parameter name that is expected by
the given JSON Service.
For example, Yahoo! Pipes supports the parameter name "_callback" for its implementation of
JSONP. Therefore, when calling Pipes, make sure to set the true name of the callback before
sending the request:
objService.setJSONP("_callback");
objService.doCall();
Note that the following two statements are equivalent, because the default JSONP name used
by the system is " callback ":
objService.setJSONP(true);
objService.setJSONP("callback");
You can also implement a callback of your own by directly modifying the endpoint URL to call
the named function. In such situations, pass false to this method, so that the transport will not
attempt any form of automated callback.
If you implement your own callback handlers, you must manually conclude the
service call with a call to the Service method doRespond, by passing the JSON object
returned from the Service back to the mapper.
For more information on fields in the Settings panel, see Input Rules.
Stub URL
To enable the Stub URL field, click the Enable button next to the field.
The Stub URL field is typically used in conjunction with the Stub Path field to support
SOAP-based web services. When SOAP is used, each request document is encapsulated by a
SOAP Envelope. The XML Mapping Utility treats the Envelope as a static document into which
the actual request is placed. For example, the default stub used by the XML Mapping Utility is
as follows:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This document is generic enough to encapsulate the majority of SOAP messages and it's
recommended that you use it.
However, if this default document does not contain enough information, you can specify the
URL for a static stub of your own. For example, you might also need to include a SOAP Header
in addition to a SOAP Body element in the Envelope.
The Stub URL value can be updated at runtime using the API call,
setOutboundStubURL. If more control is needed over the stub document and its
structures, you can provide a parsed jsx3.xml.Document instance of your own by
calling the setOutboundStubDocument() method.
Stub Path
When the stub document changes, it is often necessary to update the Stub Path to reflect the
XPath address for the node in the Stub document to which the message will be appended. To
enable the Stub Path field, click the Enable button next to the field.
Use the Stub Path field in conjunction with the Stub URL field. Type in a valid XSL query that
describes where to place the generated document in the Stub document. For example, the
following document is generated when the GetHistoricalQuotes operation is called in the
WSDL Mapping 2 sample:
<jsx1:GetHistoricalQuotes>
<jsx1:Identifiers>ibm,yhoo,goog,tibx</jsx1:Identifiers>
<jsx1:IdentifierType>Symbol</jsx1:IdentifierType>
<jsx1:AsOfDate>3-21-06</jsx1:AsOfDate>
</jsx1:GetHistoricalQuotes>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<jsx1:GetHistoricalQuotes
xmlns:jsx1="http://www.xignite.com/services/">
<jsx1:Identifiers>ibm,yhoo,goog,tibx</jsx1:Identifiers>
<jsx1:IdentifierType>Symbol</jsx1:IdentifierType>
<jsx1:AsOfDate>3-21-06</jsx1:AsOfDate>
</jsx1:GetHistoricalQuotes>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This value can be updated at runtime using the API call, setOutboundStubPath.
onBeforeSend
Enter one or more JavaScript statements in this field to execute immediately before the request
message is sent. For example, if you want to output the XML request to the System Log before
sending it, you enter the following statement, where the keyword, this, refers to the
jsx3.net.Service instance:
jsx3.log(this.getOutboundDocument().getXML());
For more information on fields in the Settings panel, see Output Rules.
Stub URL
The XML Mapping Utility provides a static mode that allows you to test against a typical
service response. This is useful in situations where the service isn't built yet or is inaccessible.
Use the Stub URL field to specify an XML document that contains a response for testing
purposes.
1. Save a valid XML document (the typical response) and enter the URL in the Stub URL
field.
2. Do one of the following to set the static mode:
Choose Project > Project Settings and change the Mode option on the
Deployment panel of the Project Settings dialog from Live to Static, and refresh
the browser to reload the project. See Deployment Panel.
Call setMode(0) on the jsx3.net.Service instance to make only that instance run
in static mode while leaving the remainder of the project in live mode.
Now when transactions are run by a service, a request isn't sent. Instead the sample document
is processed as if the remote service returned it.
Copyright © TIBCO Software Inc. All Rights Reserved.
100
This URL can also be set at runtime using the API call, setInboundURL.
onAfterReceive
JavaScript statements entered in the onAfterReceive field execute immediately after the
response message is received and before the mappings are applied. This script executes in
context of the Service instance. This means that the keyword, this, refers to the Service
instance. For example, if you want to output the XML response to the System Log palette each
time the service responds, you could write: jsx3.log(this.getInboundDocument().getXML());
/* load the xslt that will convert the axis multiref structure to a more
concrete/literal format */
var myXSL = (new jsx3.xml.XslDocument()).load("multiRefConverter.xsl");
Element
Complex
Attribute
CData
When a message rule is selected in the Rules Tree panel, the Settings panel displays a Mappings
table, a Restrictions table, and a Repeat When field.
For more information on fields in the Settings panel, see Message Rules.
1. Select a message rule in the Rules Tree panel to display the Mappings table in the
Settings panel.
2. Click the down arrow in a blank Type field of the Mappings table and select a type, such
as DOM.
3. Type a value in the Value field, if required. For example, if you selected DOM, type the
component object name. A Mapping icon now displays next to the rule in the rules
tree.
For more information on mapping GUI components, see Mapping GUI Components to
Mapping Rules.
For information on mapping response data, see Mapping Response Data to CDF GUI
Components.
Restrictions
When Schema or WSDL are used as the input, any restrictions in the input source file display in
the Restrictions table of the Settings panel. Rules that have restrictions are indicated with a
Restriction icon in the rules tree.
You can also add restrictions on a rule. For example, you might restrict user input to a five-digit
number for a field that requires a zip code. To add a restriction:
1. Select a message rule in the Rules Tree panel to display the Restrictions table in the
Settings panel.
2. Click the down arrow in a blank Type field of the Restrictions table and select a type,
such as maxLength.
3. Type a value in the Value field, such as 5. This would limit user input to a maximum of
five characters.
Repeat When
The Repeat When field is only applicable to outbound (input) messages. Enter one or more
JavaScript statements in the Repeat When field. As long as this field evaluates to true, this
specific rule is rerun.
The Repeat When field is typically used by mapping rules that convert a JavaScript array into
an XML Node-set in the outgoing message. Conceptually, this feature is similar to a do-while
loop, where execution will happen at least once and continue as long as the while (Repeat
When) statement is true.
If your mapping rule was originally created from a source WSDL, you can easily identify
message rules that are part of a collection by looking at the Restrictions table. The rule is a good
candidate for using the Repeat When field if it declares a maxLength restriction with a value of
unbounded, *, or greater than 1.
Example 1
For example, if you write a function similar to this:
window.iii= 1;
window.getNext = function() {
window.iii = window.iii+1;
return window.iii<=3;
}
and enter a call to the function in the Repeat When field for an addressToCheck rule in the
WSDL Mapping 1 sample:
window.getNext();
the JavaScript code iterates through the function three times and three records are added to the
XML message for the rule. This sample message shows the three added records.
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<jsx1:StandardizedAddress xmlns:jsx1="http://ws.cdyne.com/">
*<jsx1:addressToCheck>???</jsx1:addressToCheck>*
*<jsx1:addressToCheck>???</jsx1:addressToCheck>*
*<jsx1:addressToCheck>???</jsx1:addressToCheck>*
<jsx1:LicenseKey>
<rule_node/>
</jsx1:LicenseKey>
</jsx1:StandardizedAddress>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Example 2
Another example might be if you have an array of ids that you need to send to a server. You
can include a Repeat When statement, so that the XML Mapping Utility knows how to iterate
through this array. For example, the given web service might expect the following XML, where
the id field repeats to contain as many ids as necessary:
<ids>
<id/>
</ids>
A simple approach is to use the Array.shift() method on a Script mapping that you will bind
to the id rule. For example, if you have a global array named myArray, the Script mapping for
the id rule would look like this:
setValue( myArray.shift() );
myArray.length > 0
Because the shift method will remove the array element as soon as it is read, you can be certain
that the XML Mapping Utility will only loop as many times as it has array elements. This
results in only one node in the outgoing message for each item in the array:
<ids>
<id>a</id>
<id>b</id>
<id>c</id>
</ids>
Also note that CDF mappings automatically repeat when necessary. For more information on
CDF GUI components, see Mapping Response Data to CDF GUI Components.
To view a sample message, select an Input (request) rule or an Output (response) rule and
choose Sample Message.
1. Create the mapping rules file. See Creating Mapping Rules Files.
2. Define mappings in the rules file to map GUI components to data elements.
There are two ways to define mappings in the XML Mapping Utility:
Manual Mapping See Manually Mapping GUI Components and Input Mappings
Automatic Mapping See Automatically Generating GUI Components and Input
Mappings.
This section uses the General Interface WSDL Mapping 2 sample located in
workspace/JSXAPPS/samples/WSDL_Mapping_2. By default, this sample runs in Static
Mode, rendering the results of a sample message on screen. To run against the
Xignite web service in Live Mode, register for a license key at
http://www.xignite.com/xhistorical.asmx?op=xRegister. Then set the project to Live
Mode on the Deployment panel of the Project Settings dialog (Project > Project
Settings > Deployment) and reload your browser.
1. Expand the operation in the Rules Tree panel that you want to map to see the request
and response rules. Then expand the Input (request) child rule. Double-click the rule
with the blue down arrow to see the descendant rules. The blue down arrow
indicates that there is more content to be mapped.
For example, expand the GetHistoricalQuotes operation rule (not singular
GetHistoricalQuote*)* in the rules tree. Expand the Input (request) child rule.
Double-click the GetHistoricalQuotes rule with the blue down arrow to see its child
rules.
2. Arrange the Component Hierarchy palette and the Rules Tree panel so that components
and elements are visible.
3. Drag objects from the Component Hierarchy palette and drop them onto a rule in the
Rules Tree panel to bind GUI components to rules. Note that the mapped rule now
Other types of mappings can be created by selecting a mapping type and typing a
value in the Path/Value field. For example, a rule could be mapped to a value
specified by a JavaScript method call or to a CDF document, record, or attribute.
For information on mapping types, see Message Rules.
A Script mapping can be used to specify JavaScript code that manipulates
message structure or field data. For more information on this type of mapping, see
Using Code with Data Services.
Structured rules are typically mapped to CDF documents, records, and attributes.
For more information on this type of mapping, see Mapping Response Data to
CDF GUI Components.
4. Save the rules file as follows:
a. Click the Save button at the top of the XML Mapping Utility.
b. Navigate to the rules folder and type the filename with the .xml extension in the
Copyright © TIBCO Software Inc. All Rights Reserved.
4.
107 a.
b. Navigate to the rules folder and type the filename with the .xml extension in the
field at the bottom of the dialog. The rules folder is automatically created in your
project folder. However, rules files can be stored in any location in the project
directory.
c. Click Save in the Save File dialog to save the file.
Now that you've defined the mappings between the GUI components and the data exposed by
the service, you need to generate the JavaScript function to call the service. Then specify this
event in the Execute event of a component, such as a button. To generate the JavaScript code,
see Calling a Data Service.
This section uses the General Interface WSDL Mapping 2 sample located in
workspace/JSXAPPS/samples/WSDL_Mapping_2. By default, this sample runs in Static
Mode, rendering the results of a sample message on screen. To run against the
Xignite web service in Live Mode, register for a license key at
http://www.xignite.com/xhistorical.asmx?op=xRegister. Then set the project to Live
Mode on the Deployment panel of the Project Settings dialog (Project > Project
Settings > Deployment) and reload your browser.
If you don't want to map all the child rules to GUI components, use
Ctrl+click or Shift+click to select the rules you want to map.
Double-click the GetHistoricalQuotes rule with the blue down arrow to see the rules.
4. Select Map > DOM (map and create) from the Rules Tree panel menu.
The XML Mapping Utility generates the components and a Mapping icon in the rules
tree indicates that a rule is mapped.
You can also automatically map and generate simple GUI components for the Output
(response) rule.
Now that the mappings between the GUI components and the data exposed by the service are
defined, you need to generate the JavaScript function to call the service. Then specify this
function in the Execute event of a component, such as a button. To generate the JavaScript code,
see Calling a Data Service.
1. Double-click the rules file in the Project Files palette to open it in the XML Mapping
Utility.
2. Click the Generate button and choose the operation from the drop-down list. This
copies the JavaScript code that implements the function to the clipboard. Click OK in the
Code Generator prompt.
3. Minimize the XML Mapping Utility and open logic.js or any included JavaScript file in
your project.
4. Position the cursor in the JavaScript file and press Ctrl+v to paste the function code into
the JavaScript file. The function code has the following format:
jsx3.lang.Package.definePackage(
//the full name of the package to create
"eg.service",
//name the argument of this function
function(service) {
service.onOperation_NameSuccess = function(objEvent) {
//var responseXML = objEvent.target.getInboundDocument();
objEvent.target.getServer().alert("Success","The service call was
successful.");
};
service.onOperation_NameError = function(objEvent) {
var myStatus = objEvent.target.getRequest().getStatus();
objEvent.target.getServer().alert("Error","The service call failed.The
HTTP
Status code is: " + myStatus);
};
service.onOperation_NameInvalid = function(objEvent) {
objEvent.target.getServer().alert("Invalid","The following message node
just
failed validation:\n\n" + objEvent.message);
};
}
);
In addition to providing a mechanism for good coding practices, definePackage is also useful
because it allows the code to be introspected. This means that when an error occurs in code, a
stack trace can be run with relevant information about the call. Without this, only rudimentary
error messages provided by the browser are available.
For example, if you were to use definePackage and an error occurred somewhere in your code,
the System Log palette would display this information:
From the above information, you know that an error occurred on line 47, within the function
eg.service#doCallYetAgain(). You also know the order of the call stack and whether it
involved static or instance methods. Had you not used definePackage, the output to the error
log would look something like this:
For more information on how to use General Interface package APIs, see jsx3.lang.Package in
General Interface API Reference (Help > API Documentation).
1. Select the component in the work area or the Component Hierarchy palette.
For example, in the WSDL Mapping 2 sample, select the Query button component.
2. Choose Palettes > Events Editor to open the Events Editor palette.
3. Enter the JavaScript statement that calls the function in the Execute field in the Events
Editor palette. Be sure to enter the fully qualified name of the function:
eg.service.callOperation_Name();
This section uses the General Interface WSDL Mapping 2 sample located in
workspace/JSXAPPS/samples/WSDL_Mapping_2. By default, this sample runs in Static
Mode, rendering the results of a sample message on screen. To run against the
Xignite web service in Live Mode, register for a license key at
http://www.xignite.com/xhistorical.asmx?op=xRegister. Then set the project to Live
Mode on the Deployment panel of the Project Settings dialog (Project > Project
Settings > Deployment) and reload your browser.
1. In the Rules Tree panel of the XML Mapping Utility, select the immediate parent of the
element that corresponds to a record in the CDF document.
In this example, the parent element is GetHistoricalQuotesResult, because it contains the
repeating HistoricalQuote elements that will map to records in the CDF document.
2. In the Mappings table of the Settings panel, select CDF Document from the drop-down
list in the Type column of the Mappings table.
3. Type a cache ID string for the CDF document in the Path/Value column.
For the WSDL Mapping 2 example, type historicals.
This value becomes the cache ID of the CDF document, which appears in the Local Data
Cache palette after the response is received and inbound mapping logic is applied. If the
file exists, it's overwritten. If the file doesn't exist, a new file is created in the cache.
In the WSDL Mapping 2 example, the rules file looks like this:
4. Select the element in the Rules Tree panel that corresponds to a record in the CDF
document.
In the WSDL Mapping 2 example, the element that corresponds to a CDF record is
HistoricalQuote, which is the repeating rule.
5. Select CDF Record from the drop-down list in the Type column in the Mappings table.
It's not necessary to specify a value in the Path/Value column for this exercise.
You can also select an element in the rules tree and choose Map > CDF Record.
Although the Path/Value field is not required, it can be used to support recursion or
hand off processing to another rule. For example, if there is another rule in your
mapping rules file that has a CDF Record mapping, you can enter the jsxid for that
rule. To find the jsxid (Rule ID), select the rule that you wish to call and click the
Rule Node Profile radio button.
When a repeating rule is mapped to a CDF record, by default the rules file automatically
iterates through each corresponding node in the concrete message.
In the WSDL Mapping 2 example, the rules file looks like this:
1. Select an element to map in the Rules Tree panel. For example, select Date.
2. Select CDF Attribute from the Type drop-down list in the Mappings table.
3. Type a string value in the Path/Value field. This value becomes the attribute name in the
CDF document. For example, type Date for the Date element.
You can also select an element in the Rules Tree panel and choose Map >
CDF Attribute. The attribute name is automatically generated in the
Path/Value field.
In the WSDL Mapping 2 example, the rules file looks like this:
4. Follow the same process to create mappings for other elements to include in the CDF
document: select the element, select CDF Attribute as the Type, and enter a name for the
Copyright © TIBCO Software Inc. All Rights Reserved.
115
4.
document: select the element, select CDF Attribute as the Type, and enter a name for the
corresponding CDF attribute.
In the WSDL Mapping 2 example, the rules file looks similar to this:
If the response has nested rules, you can replicate the nested structure using CDF Record
and CDF Attribute mappings.
The jsxid attribute, which is required in every CDF document, acts as a key. You can
map an existing element that acts as a key value, such as a date or other unique value, to
jsxid. If no such mapping exists, the XML Mapping Utility automatically adds a jsxid
attribute to the CDF document and generates a unique value.
1. Select the top-level GUI object that will consume data in the Component Hierarchy
palette. In the WSDL Mapping 2 example, the top-level object is a Matrix component,
gridResults, with six columns.
2. Open the Properties Editor palette and specify the name of the cache document for the
XML Cache ID property. In the XML Mapping Utility, this is the value in the Path/Value
column for the CDF Document mapping. In this example, the value is historicals :
3. Select the GUI object in the Component Hierarchy palette that will display the data
series. In the WSDL Mapping 2 example, the object is a column in the matrix, such as
date, security, open, and so on.
4. Open the Properties Editor palette and type the attribute name in the Value field of the
Att Name property.
In this example, choose date in the Component Hierarchy palette and type Date, the
attribute name, in the Att Name field to map the date component to the CDF Date
attribute.
5. Repeat the process for other GUI objects until all series mappings are complete: select
each object in the Component Hierarchy palette and type the appropriate CDF attribute
name in the Value field of the Att Name property.
Next, you need to test the rules file to be sure the mappings are correct. To test the rules file, see
Running a Quick Test.
Setting Up a Test
To set up a test, specify values for each mapped element to simulate user input. There are two
ways to simulate input:
To specify values in the Mappings table, complete these steps in the XML Mapping Utility:
This section uses the General Interface WSDL Mapping 2 sample located in
workspace/JSXAPPS/samples/WSDL_Mapping_2. By default, this sample runs in Static
Mode, rendering the results of a sample message on screen. To run against the
Xignite web service in Live Mode, register for a license key at
http://www.xignite.com/xhistorical.asmx?op=xRegister. Then set the project to Live
Mode on the Deployment panel of the Project Settings dialog (Project > Project
Settings > Deployment) and reload your browser.
1. In the application work area, appCanvas.xml, simulate user input by entering data in the
application.
For example, enter stock symbols in the WSDL Mapping 2 example and choose a date.
2. Select an operation rule, such as GetHistoricalQuotes, in the Rules Tree panel of the XML
Mapping Utility. Right-click the rule and select Execute (Quick Test).
When the response is received, a file with the specified name displays in the Local Data
Copyright © TIBCO Software Inc. All Rights Reserved.
2.
118
When the response is received, a file with the specified name displays in the Local Data
Cache palette. This file exists in the cache instance used by the current component. In the
WSDL Mapping 2 example, the file name in the Local Data Cache palette is historicals.
If you open this file, you'll see the response data from the service.
3. Return to the work area to see the updated information in the mapped component. If the
updated information isn't displayed, complete these steps:
a. Select the top-level GUI component that consumes the data in the Component
Hierarchy palette.
In the WSDL Mapping 2 example, select the gridResults component.
b. Click the Repaint button in the Component Hierarchy palette.
The Test Interface Tool is designed to guide you through the test sequence. The Create, Send,
Receive, and Apply tabs correspond to phases of sending and receiving XML messages.
Clicking a tab displays data that is relevant to the current test phase.
Before running a test, you can set breakpoints at various steps in the test sequence or you can
also test a rules file without breakpoints. For more information, see Setting Breakpoints.
Mapper Log
You can also use the Mapper Log to view the results of a message exchange. Use the Adjust Log
Level button to select a log level before you begin testing.
Running a Test
To run a test in the Test Interface Tool, complete these steps:
1. Click the Test button on the Rules Tree panel toolbar to open the Test Interface Tool.
2. Select the operation to test from the Select drop-down list at upper left.
The Create tab displays mappings for the outbound message and the following fields:
Rule Name contains the name of the element.
Type shows the type of object that is mapped.
Path/Value contains the GUI component name or any associated JavaScript code
for this mapping.
Post-Mapping Filter/Handler contains filter code to execute before sending the
message.
3. Click the Start Test button next to the Outbound Mappings label to start the test. If
you didn't set any breakpoints and there aren't any errors, the test runs and cycles
through each tab: Send, Receive, and Apply. When the test is complete the Create tab
displays again.
4. If a breakpoint was set, the test advances to the Send tab. For more information, see
Setting Breakpoints.
The Send tab displays the outbound message and the following fields:
URL contains the URL specified in the WSDL file.
HTTP Headers contains header content for the message. The header text can be
customized by editing this value.
Name and Password are used for services requiring HTTP authentication.
Copyright © TIBCO Software Inc. All Rights Reserved.
121
Name and Password are used for services requiring HTTP authentication.
Method defines the method for contacting the Service. The most common are GET
and POST.
5. If a breakpoint was set, click the Resume button to advance to the next step. The
outbound message is sent to the data service, and the response is displayed in the
Receive tab. Because the Receive tab doesn't have a breakpoint, the test continues to the
Apply tab. Click the Receive tab to see the response.
message. Click the Generate Alternate Inbound Message button to the left of
the Response field. A response message for the specified operation is copied to the
Response field.
6. If the Test Interface Tool doesn't automatically advance to the Apply tab, click the Apply
tab to advance to the next step.
This is the final step in the testing process. If filtering logic and mappings executed without
errors, the Create tab displays to allow you to start another testing cycle.
For a step-by-step example of running a test with the Address Lookup example, see Testing
Mappings.
Setting Breakpoints
Before running a test, you can set breakpoints for viewing request and response messages at
each step in the process. Breakpoints can be set at the following steps:
You can also test a rules file without breakpoints. However, it is usually helpful to view the test
results after each step. When advancing from one breakpoint to the next, you can return to the
previous breakpoint to retest only that step in the process. After modifications to mapping
rules, changes can be tested from the last breakpoint.
To set a breakpoint and run a test with breakpoints in the Test Interface Tool, complete these
steps:
1. Click any tab that displays a Breakpoint button , such as the Create, Send, or Apply
tab.
2. Click a Breakpoint button to set a breakpoint.
3. Click the Create tab and run the test as described in Running a Test. The test stops at any
step that has a breakpoint set.
4. Click the Resume button to advance to the next step.
Setting Filters
Filters can be applied to messages before an input message (request) is sent or after an output
message (response) is received and before the mappings are applied. This is useful when you
want to modify requests and responses.
You can enter JavaScript code to run as a filter on message rules. There are two ways to set a
filter for message rules:
Filters are useful for manipulating input and output messages as they travel between the client
and the server. For example, the XML Mapping Utility doesn't support multiRef structures that
are sometimes used to describe SOAP messages on Apache Axis servers. However, you can use
the onAfterReceive event handler to manipulate the output message from the server before
running the inbound mapping rules. Since you can't control your server environment, you
could write an XSLT that would convert the multiref indirection to a supported XML Mapping
Utility format. This transformation would occur on the client after the message is received. For
more information on this multiRef example, see onAfterReceive multiRef Example.
Further Information
For more tutorials and sample applications, see:
Handling Errors
When an operation generates an error, the error information is returned to the Request object
for the response. You can write a JavaScript function that gets the error information, adds
business logic for handling the error scenario, and displays the error to the user.
HTTP errors can be determined by calling getRequest on the Service instance and then
querying the jsx3.net.Request object for its status (getStatus) and status description (
getStatusText).
SOAP faults can be processed by mapping to the fault rules that are created by the XML
Mapping Utility when the WSDL is parsed (assuming the WSDL defines them).
Formatting errors, such as a string in a number field or an enumerated value not being
entered, can be determined by subscribing to the ON_INVALID subject for the service
instance. When an error is encountered during message generation, the specified
callback function is notified.
JavaScript errors display in the System Log palette for General Interface Builder.
The example application allows a user to input a zip code and click a button to send the zip
code data to the web service. The web service receives the user input and sends a response that
returns the matching city and state.
The example application is also available as a General Interface sample. To open the sample,
choose Project > User Projects > Samples > WSDL_Mapping_1.
Before you begin this tutorial, you must create the application in General Interface Getting
Started.
1. Create a mapping rules file that defines mappings between application objects and data
elements.
2. Define mappings in the mapping rules file.
3. Generate the function code that calls the web service.
4. Invoke the function code.
5. Test the mappings.
For more information on mapping and the XML Mapping Utility, see Communicating with
Data Services.
For an introduction to the General Interface Builder user interface, see General Interface Getting
Started.
Rules files use the Common Exchange Format (CXF) for translating between application
formats and web services. For information about CXF, see Common Exchange Format (CXF).
After you click the Parse Document button, you see the Rules Tree panel as shown here:
Defining Mappings
In this step, you'll define mappings between the GUI components of the myAddressLookup
application and the data exposed by the web service.
The Address.wsdl file used in the myAddressLookup project defines several operations.
Because you only use one operation for the myAddressLookup application, ReturnCityState ,
you can remove all other operations for the rules file as they aren't needed.
1. Select the ReturnCityState operation in the Rules Tree panel. Confirm that it's the correct
rule by reading the Schema source in the pane below:
<operation name="ReturnCityState">
2. Delete all other operations by selecting Delete > Unselected Sibling Rules.
3. Arrange the Component Hierarchy palette and the Rules Tree panel so that components
and mapping rules are visible.
4. Create a mapping between the txtZipcode component and the zipcode rule as follows:
a. Expand the ReturnCityState rule in the Rules Tree panel.
b. Expand the Input (request) rule and double-click the ReturnCityState child rule.
The ReturnCityState request has two input rules: zipcode and LicenseKey.
c. Drag the txtZipcode component from the Component Hierarchy palette to the
zipcode rule in the Rules Tree panel. The following mapping is created in the
Copyright © TIBCO Software Inc. All Rights Reserved.
128
c.
zipcode rule in the Rules Tree panel. The following mapping is created in the
rules tree.
Notice in the Mappings table to the right that the Type is DOM (Document Object
Model), representing a mapping between a GUI component and a rule in the rules
tree.
The value is txtZipcode, the name of the GUI component.
Next, you'll use the setValue() method to set the license key value to use the
evaluation license ("0"). The evaluation license provides limited access to the
service during testing. If the designated number of requests is exceeded, an error
is returned.
5. Set the value for the license key as follows:
a. Click the LicenseKey rule in the Rules Tree panel.
b. Select Script from the drop-down list in the Type column of the Mappings table.
1. Expand the Output (response) rule and double-click the ReturnCityStateResponse rule.
2. Double-click the ReturnCityStateResult rule to expand it to see all the children.
You'll only use two of the output rules: City and StateAbbrev.
3. Select the output rules City and StateAbbrev, and delete all other operations by selecting
Delete > Unselected Sibling Rules.
4. Drag the txtCity component from the Component Hierarchy palette and drop it on the
City rule in the Rules Tree panel.
5. Drag the txtState component from the Component Hierarchy palette and drop it on the
StateAbbrev rule in the Rules Tree panel.
6. Save the rules file as follows:
a. Click the Save button at the top of the XML Mapping Utility.
b. Open the rules folder in the Save File dialog and type GetCityandState.xml in the
field at the bottom of the dialog.
c. Click Save to save the file.
Now that you've defined the mappings between the GUI components and the data exposed by
the service, you need to generate the JavaScript function to call the service. This is the same
function that is defined for the button's Execute event in General Interface Getting Started.
Recall that in one of the last steps of the "Creating an Application" tutorial in General Interface
Getting Started, you configured the Find City and State button to execute the JavaScript
function eg.service.callReturnCityState();. In this section, you generate the function code
and add it to your project.
To generate the function code that invokes the web service, complete these steps:
1. Click the Generate button next to the Delete button in the XML Mapping Utility and
choose ReturnCityState from the drop-down menu in the Rules Tree panel menu. Resize
the Rules Tree panel if you don't see the button.
The JavaScript code for invoking this operation is copied to the clipboard. The code
defines a JavaScript function that creates a service instance. The service instance uses the
rules file to create the XML request document as well as process the service's XML
response document.
2. Click OK in the Code Generator prompt, which displays a message that the JavaScript
Copyright © TIBCO Software Inc. All Rights Reserved.
130
2. Click OK in the Code Generator prompt, which displays a message that the JavaScript
code has been copied to the clipboard.
3. Click the Minimize button in the XML Mapping Utility.
4. Click the logic.js tab in the General Interface Builder work area.
This file contains business logic for your application. It should be empty except for a
comment line.
5. Delete the comment line and press Ctrl+v to paste the contents of the clipboard into
logic.js.
The JavaScript code in the logic.js file should look like the following:
jsx3.lang.Package.definePackage(
"eg.service",
//the full name of the package to create
function(service) {
//name the argument of this function
service.callReturnCityState = function() {
var objService = myAddressLookup.loadResource("GetCityandState_xml");
objService.setOperation("ReturnCityState");
service.onReturnCityStateSuccess = function(objEvent) {
//var responseXML = objEvent.target.getInboundDocument();
objEvent.target.getServer().alert("Success",
"The service call was successful.");
};
service.onReturnCityStateError = function(objEvent) {
var myStatus = objEvent.target.getRequest().getStatus();
objEvent.target.getServer().alert("Error","The service call failed.
The HTTP Status code is: " + myStatus);
};
service.onReturnCityStateInvalid = function(objEvent) {
objEvent.target.getServer().alert("Invalid","The following message
node just failed validation:\n\n" + objEvent.message);
};
}
);
After the Find City and State button is clicked and the web service is called, the function
displays an alert dialog containing the text The service call was successful.
Confirm that you entered the JavaScript statement that calls the function that invokes the web
service.
Testing Mappings
The XML Mapping Utility includes features for verifying inbound and outbound messages
generated using a rules file. The entire test sequence consists of executing outbound mappings,
generating the outbound message, sending the message, receiving the response, and executing
inbound mappings. Outbound and inbound filtering logic can also be entered and verified.
1. Simulate user input by manually typing a valid 5-digit or 9-digit zip code in the Type
Zip Code field in the work area. For example, type 11357 in the Type Zip Code field.
2. Select the LicenseKey input rule in the Rules Tree panel in the XML Mapping Utility.
Confirm that you selected Script as the Type and entered setValue("0") in the
Path/Value column of the Mappings table. If you haven't, refer to the instructions in
Defining Mappings.
3. Click the Test button on the XML Mapping Utility toolbar to open the Test Interface
Tool.
4. Select ReturnCityState from the drop-down list at upper left.
5. Before testing the mappings, insert breakpoints for viewing request and response
messages at each step in the process.
a. Click the Send tab and click the Pause Before Sending the Message button to
insert a breakpoint.
b. Click the Apply tab and click the Pause Before Executing Inbound Mappings
button next to the Inbound Mapping header to insert a breakpoint.
6. Click the Create tab. The Outbound Mappings panel lists the bound request parameters
and mapping information.
7. Click the Start Test button next to the Outbound Mappings header to begin testing
the mappings. When the message is generated, the message displays in the Send tab.
133
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<jsx1:ReturnCityState
xmlns:jsx1="http://ws.cdyne.com/"><jsx1:zipcode>11357
</jsx1:zipcode><jsx1:LicenseKey>0</jsx1:LicenseKey>
</jsx1:ReturnCityState>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The zip code you specified in the dialog should display as the contents of the
jsx1:zipcode element. For example,
<jsx1:zipcode>11357</jsx1:zipcode>
If the message code is incorrect, return to the XML Mapping Utility and verify that
bindings are correctly specified before proceeding.
9. Click the Resume Test (Send Message) button next to the URL field. The outbound
message is sent to the web service. When a response is received, the message displays in
the Receive tab and the XML Mapping Utility automatically advances to the Apply tab.
10. Click the Receive tab to view the inbound message. City and state information is
returned in the City and StateAbbrev elements. However, this data has not yet been
bound to any text boxes. If you view the application in the work area, the City and State
fields are still blank.
11. Click the Apply tab. The Test Interface displays inbound mappings to text boxes.
12. Click the Resume (Execute Inbound Mappings) button next to the Inbound
Mappings header. In the work area, you can see that inbound mappings are applied to
text boxes. The City and State fields have a blue background because the fields are
disabled. This is to prevent users from entering data in these fields.
The testing cycle for this data service configuration is complete, and the XML Mapping
Utility cycles back to the Create tab.
This concludes the tutorial. For other examples of connecting to web services, see samples in
workspace/JSXAPPS/samples and on the Developer Network at http://www.generalinterface.org.
4. Add two text boxes to the mapping container---drag two text boxes from the Form
Element component library to the cdf mapping container, and name them T1 and T2:
5. Look at the Properties Editor for the cdf element---the XML String property contains this
Value:
<data jsxid="jsxroot">
<record jsxid="1" first="john" last="public" middle="q"/>
</data>
This is the default test document that is provided with the control. Like all other controls
that implement the Cacheable interface, this control will parse this string of XML and set
it in the local cache, using a unique ID (or one assigned by the developer if applicable).
6. Open the Local Data Cache, and you'll see that the CDF mapping container has put the
_jsx_1_4_XML file there:
7. Double-click the XML file name to open it in the work area, then click the Formatted
Source XML button to see the formatted XML:
1. Open the Local Data Cache and find the CDF document.
6. In the Properties Editor for the T1 component, change the CDF Record Id value from 1 to
2, to change the name in the T1 text box:
This exercise illustrates how you can make each form be a separate data store---it always reads
the value of the CDF Record Id, regardless of how the CDF control for the form is mapped.
Inherit a document from an ancestor CDF, or it can provide its own document.
Map the records of an ancestor CDF, or provide its own mapping.
You can continue nesting components inside components in the CDF mapping container, so
that each nested component becomes a separate data item. Whichever container is the last in the
nested chain determines the final mapping.
In this example, the T1 text box originally contains the value of CDF record ID 2, which is jane.
Using the API setCDFId, we change the T1 text box value from record 2 ( jane) to record 1 (john
):
For sample applications that demonstrate best practices, visit Developer Network at
http://www.generalinterface.org.
Application Design
List of Best Practices
Faster Load Times
JavaScript Code
API Usage
Components and Component Serialization Files
Benchmarking Performance
Application Design
One of the critical phases of software design is application design. When designing your
application, it's important to consider the following:
Application design includes application architecture, user interface design, and component
design. If this phase of application development is neglected, usability and performance can be
adversely affected. For example, poor performance can occur if the application has a poorly
designed, complicated user interface and if the application uses components that aren't
designed properly. While designing your General Interface application, consider the following
best practices.
Load only those areas of the application that are viewable by the user and required for
the user to begin using the application. For example, load the tab content for the first
visible tab and load content of other tabs only when the user selects the tab.
Specify an appropriate load type for your GUI components, such as Paint
Asynchronously, Deserialize Asynchronously, and so on. For more information, see
General Interface Component Guide.
Load GUI components using Referenced - Asynchronous. For more information, see
Component Hierarchy Palette Context Menu.
Load XML data sources asynchronously. For more information, see General Interface
Component Guide.
Application Design
Design Applications to be Asynchronous
Reuse Existing Components
Don't Store Data in Form Elements
Components and Component Serialization Files
Eliminate Unnecessary Components
Use Matrix and Paging
API Usage
Minimize Repainting
Search Components in the DOM Efficiently
Copyright © TIBCO Software Inc. All Rights Reserved.
142
General Interface 3.4 includes a more efficient startup mechanism. General Interface 3.4 and 3.5
include significant performance enhancements, especially for Internet Explorer 6.
Upgrade Browsers
When possible, use the latest browsers supported by General Interface. Also, as you develop
your application, benchmark your application in all browsers and versions used by your end
users. Benchmarking in all browsers prevents unexpected performance issues after deployment.
For example, Internet Explorer 6 is slower than Firefox.
Note that subsequent Internet Explorer releases are significantly faster than
Internet Explorer 6.
JavaScript Code
Use the following best practices when developing JavaScript code for your application.
to List:
Use jsx3.net.Service.compile()
Use the jsx3.net.Service.compile() method to compile the CXF rules for a service instance to
an equivalent XSLT document. This enables much faster performance than using the
DOM-based iterator (default) to convert the XML response document into a CDF Document
type. Call this method immediately before or after the doCall() method for best performance.
In Internet Explorer 6, beware of String and RegExp literals in loops. For best
performance, declare these literals statically or declare them outside of loops.
API Usage
When writing JavaScript code for your application, use the following best practices.
Minimize Repainting
The on-screen rendering of HTML is often the slowest aspect of browser-based applications.
Using efficient repaints can make your application faster and more responsive to user input.
Look for unnecessary repaints in your JavaScript code and remove them.
Use the General Interface debug build to identify multiple repaints. See Use the General
Interface Debug Build.
Repaint the smallest area of your application to obtain the desired effect.
Understand how set methods may cause repaints and use them appropriately. See How
Set Methods May Cause Repaints.
Avoid redundant repaints on the same object.
When calling any load APIs, such as the jsx3.app.Model.load(),
jsx3.app.Model.loadAndCache(), and jsx3.app.Model.loadXML() methods, pass false as
the second parameter to avoid a repaint if changes will be made to the component. Then
repaint the component after changes are complete using the
jsx3.gui.Painted.paintChild() method.
Some methods, such as removeChild(), setChild(), and adoptChild(), can trigger
repaints of the parent whose child is removed, set, or adopted. When possible, reuse
components instead of removing and loading them.
If removing multiple children at the same time, use the
jsx3.app.Model.removeChildren() method to avoid multiple repaints.
For Matrix components, call the repaintData() method if only the data has changed.
The repaintData() method paints only the data rows and doesn't recalculate and
re-profile the box profile and resulting XSLT. Therefore, the repaintData() method is
more efficient than the repaint() method.
HTML DOM update: this is a fast, inexpensive paint, where a change to the General
Interface DOM is transmitted directly to the browser DOM.
Paint/repaint: this is a slower, more expensive paint, where the General Interface DOM is
first serialized to an HTML string and then replaces part of the browser DOM.
1. If the set method doesn't have a final boolean parameter (bRepaint), the component isn't
repainted. For example, jsx3.gui.Block.setBackground(strBG). However, there are
some exceptions.
2. If the set method has a final boolean parameter (bRepaint), you control the behavior. The
default setting is false, meaning the component isn't repainted. For example,
jsx3.gui.Block.setText(strText, bRepaint).
If the final boolean parameter is set to true, the component is repainted, which is usually
an inexpensive HTML DOM operation. However, in some cases a full repaint occurs.
1. For methods that call inexpensive HTML DOM repaints, call each method with true.
2. If one of the methods calls a more expensive, full repaint, call that method last, while
calling bRepaint=false to the preceding set methods.
Don't use jsx3.GO() to search the General Interface DOM, because it has access to all
loaded General Interface applications and searches all of them for a DOM node of
the given name. Recommended usage is in the General Interface Builder JavaScript
Console only.
jsx3.app.Server.getJSXByName()
jsx3.app.Server.getJSXById()
jsx3.app.Model.getAncestorOfType()
jsx3.app.Model.getDescendantOfName()
For example, you could use the getAncestorOfType() method in a dialog button execute event
to close a dialog:
this.getAncestorOfType(jsx3.gui.Dialog).doClose();
General Interface also provides DOM methods that use familial relationships to locate objects.
Depending on the location of the object you're searching for, it may be faster to use these
methods. For example, calling
object.getChild('myblock');
only checks its direct children, so it might be much faster than calling
object.getDescendantOfName('myblock');
For more information on General Interface APIs, see General Interface API Reference. For
information on how to search the General Interface DOM safely when deploying multiple
applications in the same web page, see Protecting Namespaces in Multiple Application
Environments.
In this example, messages won't be generated if the com.tibco logger is configured as OFF:
Benchmarking Performance
Use the following tools and General Interface features to assist you in benchmarking
application performance.
Firebug http://www.getfirebug.com
jsLex http://rockstarapps.com/pmwiki/pmwiki.php?n=JsLex.JsLex
The General Interface Test Automation Kit is available from the download site at
http://www.generalinterface.org.
There are two general scenarios for accessing a General Interface application, local provisioning
and remote provisioning. Local provisioning doesn't require configuration if default browser
security settings are used. Remote provisioning requires configuring proxy communication or
modifying default browser security settings.
Local Provisioning
Remote Provisioning
Local Provisioning
With local provisioning, the application files and the General Interface Framework are located
on the same machine as the web browser. When the application is accessed, the browser loads
required files into cache using a file URL, for example file:\\C:\tibco\gi\GI_Builder.html.
With the default browser settings, there are no restrictions on communicating with web servers
outside the subdomain.
Local Provisioning
Remote Provisioning
With remote provisioning, the deployed application files and the General Interface Framework
are located on a web server. A browser on a remote machine accesses the files using an HTTP
URL and loads files into cache. When an HTTP URL is used, default browser security settings
prevent your application from communicating with web servers outside the subdomain. The
following figure illustrates the remote provisioning scenario before any configuration is
performed.
Apache Install and configure the mod_proxy module. Then use the ProxyPass directive
to route responses through the General Interface application domain server, such as
www.mydomain.com, rather than a web server outside the subdomain. For details, see
the Apache HTTP Server documentation at http://httpd.apache.org.
Microsoft IIS Install and configure the Microsoft Internet Security and Acceleration (ISA)
Server. Write an ISAPI Filter to perform reverse-proxying or use an equivalent
third-party product. The software must intercept an HTTP Request made to the General
Interface application domain server, such as www.mydomain.com. Copy the entire
HTTP header packet, change the HTTP Host header, and perform a new HTTP Request
using the WinHttp API. For details, see
http://www.microsoft.com/isaserver/default.mspx.
Custom Write a server process, such as a servlet, .NET service, or web service, that acts
as a proxy between the General Interface application domain server and other
subdomains.
jsx3.Package.definePackage("eg.proxy", function(proxy) {
/**
* Converts a non-proxied URI to a proxied URI if PROXY is true.
* <p/>
* <code>http://www.domain.com/service/op</code> will be converted to
* <code>http://PROXY_HOST/PATH_PREFIX/www.domain.com/service/op</code>
*
* @param strURI {String} the URI to convert
* @returns {String} the converted URI
*/
proxy.convertURI = function(strURI) {
if (proxy.PROXY) {
var uri = new jsx3.net.URI(strURI);
if (uri.getHost() != proxy.PROXY_HOST &&
(uri.getScheme() h1. "http" || uri.getScheme() "https")) {
return jsx3.net.URI.fromParts(uri.getScheme(), null,
proxy.PROXY_HOST,null, proxy.PATH_PREFIX + uri.getHost() +
uri.getPath(), null, null).toString();
} else {
return strURI;
}
} else {
return strURI;
}
};
/**
* Open all requests with this method to ensure that URLs are properly
* converted for proxy.
*/
proxy.openRequest = function(strURL) {
var objRequest = new jsx3.net.Request();
objRequest.open("GET", proxy.convertURI(strURL));
return objRequest;
};
/**
* Open all services with this method to ensure that URLs are properly
* converted for proxy.
*/
proxy.openService = function(strRulesURL, strOpName) {
var objService = new jsx3.net.Service(strRulesURL, strOpName);
objService.setEndpointURL(proxy.convertURI(objService.getEndpointURL()));
return objService;
};
});
This option is only available for Internet Explorer. For Firefox, you must configure
proxy communications. See Configuring Proxy Communication.
When the security settings are set to accept the subdomain where the application is deployed as
a trusted site, the browser allows direct communication with web servers outside the
subdomain.
To modify Internet Explorer browser settings on a client machine, complete these steps:
7. Type the name of the subdomain where the application is deployed in the Add this Web
Copyright © TIBCO Software Inc. All Rights Reserved.
156
7. Type the name of the subdomain where the application is deployed in the Add this Web
site to the zone field, and then click OK.
8. Click OK again to close the Internet Options dialog.
There are several ways to add custom JavaScript to an application. The code is processed
differently depending on how it's specified.
In General Interface Builder, fields where you can specify JavaScript code are
distinguished visually with a light blue graph pattern background.
The following table shows the locations in General Interface Builder where you can specify
code and the impact of each method.
XML JavaScript statements execute in context of the mapped XML message node
Mapping being processed or created.
Utility
Project JavaScript statements execute during the onLoad event in application (server)
Settings context immediately after the root and body canvases are drawn on-screen.
dialog JavaScript statements execute during the onUnload event when the browser
window is unloaded.
JavaScript A file containing JavaScript statements, method calls, constants, and so on can
file be included in a project. Any static execution is evaluated before components
included in are loaded.
project
JavaScript Any JavaScript statements can be checked for errors before adding them to the
Console application.
To associate JavaScript code with an event, type the code in the Value field in the Events Editor
palette, as shown here.
The statements doListClick() and doShowDetails() are defined in an included JavaScript file
that is loaded when the browser first initialized. It is considered best practice to keep event
binding code to a minimum, managing the bulk of the presentation logic in a JavaScript
include. For more information, see Including JavaScript Files.
Each component, which is represented by a tab in General Interface Builder, exposes a subset of
fields within the Component Profile view. To execute JavaScript statements before or after
Executing JavaScript statements before an object is deserialized is useful when the runtime
needs to be prepared before the component is loaded. For example, when data that is used by a
component needs to be preloaded.
Executing JavaScript statements after an object is deserialized is useful when the component
needs to be initialized with information only available at runtime. For example, the object ID
(which is created after deserialization) can be displayed in the caption bar of a dialog. The most
common use for serialization event bindings is to configure generic, reusable components with
runtime-specific information.
In both cases, the JavaScript statements are executed only if the component is loaded at
runtime.
Executing code to set a dynamic property value. See Specifying Code in Dynamic
Properties.
Specifying the onLoad script. See Executing Code When the Application Loads.
Specifying the onUnload script. See Executing Code When the Application Unloads.
JavaScript files can be created in General Interface Builder and are automatically added to your
project.
A default JavaScript file, logic.js, is created and included in your project when the project is
created. This file initially contains no code, and can be deleted from the project as needed. You
can add JavaScript code to logic.js, or create one or more new files, partitioning code among
them. For smaller applications, a single included JavaScript file is usually sufficient. For larger,
more complex applications, it can be helpful to divide the code among multiple files according
to feature area, class, or functional role.
To add a JavaScript file to your project, select File > New > JavaScript File. A new tab is added
to the work area for editing the file contents.
When saving files in the work area, you can save changes to disk (Save), save to disk and
Copyright © TIBCO Software Inc. All Rights Reserved.
163
When saving files in the work area, you can save changes to disk (Save), save to disk and
update changes in browser memory (Save and Reload), and load or reload from disk into
browser memory (Load/Reload). Files must be loaded into memory to be part of the live
application.
By default, logic.js is configured to automatically load after the General Interface system files
have loaded but before the application initializes. Other included JavaScript files can also be
loaded automatically by right-clicking the file in the Project Files palette and selecting the Auto
Load option. If a file is required only for a specific module, you can load the file when needed
using the loadResource() method of the Server class.
For more information on the Auto Load options, see File Profile Dialog. For information on
dynamic class loading, see Class Loading in General Interface.
Dynamic properties files execute their contained JavaScript only once, when they are first
loaded into the application. This means that the DateNow field in the above screenshot will
reflect the date/time when the dynamic properties file first loaded.
1. Open an existing dynamic properties XML file or create a new one. See Creating
Dynamic Properties Files.
2. Check the Eval checkbox for the property to indicate that the value should be evaluated
as code.
3. Type one or more JavaScript statements separated with semicolons in the Value field.
To execute JavaScript code when an application loads, select Project > Project Settings >
Deployment and type the code in the onLoad Script field. In the following figure, init() is a
global function defined in a JavaScript project resource.
Executing JavaScript code before the application loads is useful for performing tasks that
should complete before a user accesses your application. For example, you could add code that
checks for the presence of an HTTP cookie before displaying a login dialog.
There are several ways to unload a browser window, including closing the window, refreshing
the window, or navigating to another URL. The onUnload event allows you to save user state
and do any final cleanup before exiting. This script can include one or more JavaScript
statements which execute in context of the Server. The variable, this, references the
jsx3.app.Server instance.
The onUnload event only fires when the browser is being unloaded. If you want to warn the
user before the page is unloaded, use the onBeforeUnload event as defined for the given
browser. For example,
jsx3.gui.Event.subscribe(jsx3.gui.Event.BEFOREUNLOAD, function(objEvent) {
objEvent.returnValue = 'If you leave this page, your session will end.'; });
To associate JavaScript code with a data service call, type the code in the Path/Value column in
the Mappings table of the XML Mapping Utility and set the Type value to Script. In this context,
the execution context is an instance of the jsx3.net.Service class. In the Path/Value column,
you can execute any method of the jsx3.net.Service class using the syntax this.method_name.
When sending data to a data service, you can write code to specify a value that is unknown at
design time. For example, you could specify the license key for using the data service at
runtime, then you could pass the license key in the message using the setValue() method.
When receiving data, you can use this feature to filter and validate return values or parse data
into the format required by your application. For example, you can extract the value of an
outcome element in a response and use that value to control conditional execution in a
component callback handler.
The JavaScript console replaces the JavaScript Test Utility that was available prior to
General Interface Release 3.9.
To open the JavaScript console, choose Tools > JavaScript Console in General Interface
Builder.
In the console, you can use the up and down arrow keys to scroll through the command
history. The history is saved even after General Interface Builder is closed and reopend. For
example, if you enter the command document.body or jsx3 in the console, the string
representation of an object is shown with a collapsed arrow to its left. You can click the arrow to
expand the object. Any nested objects can also be expanded.
Property keys are shown in purple, except when the value of the property is inherited from the
object's prototype, in which case the key is shown in gray. Function and Array outputs are also
shown.
To clear the console history, type Ctrl+K or right-click inside the console and choose Clear
Console.
By default, the console evaluates the input when you press Enter. The console supports
multi-line input. You can paste the multi-line text at the prompt or type Shift+Enter to insert a
carriage return.
Code Execution
All code evaluated by the JavaScript console is executed in window scope. For example, if you
evaluate the following statement:
f = 1;
you have actually set the property f of the top-level object window. If you set a global variable
in this way, it becomes available to subsequent expressions that you evaluate in the console.
The form var f = 1; does not have the same behavior as f = 1;. The value of f is
not available to subsequent expressions if it is set in this way.
If the active editor is a JSX component editor then each DOM node in the component is exposed
as a variable in the JavaScript console. For example, if the component contains an instance of
jsx3.gui.TextBox whose name is set to "textBox," then the variable textBox will be equal to the
TextBox instance when evaluated in the console. Please note that,
Only objects whose names are valid JavaScript variable names are exposed. The name
must match [\$a-zA-Z_][\$\w]*.
The behavior of name collisions is not defined. If you have two or more objects in the
same component with the same name, the corresponding variable may reference either
one.
The prototype field of the class function represents the prototypical instance of the class. A new
instance of the class will be a copy of the prototype, including any fields and methods placed in
the prototype.
Plant.prototype.getLatinName = function() {
return this.latinName;
};
Inheritance is supported by setting the prototype of a class function to a new instance of the
superclass:
Tree.prototype.isFlowering = function() {
return this.flowering;
};
Because all classes implicitly extend the Object class, the following statement is also true: (var
aPlant = new Plant()) instanceof Object;
Obtaining the class that defines an instance with the getClass() method
Calling an overridden method in a superclass with the jsxsuper() and jsxsupermix()
methods
A better toString() method that overrides Object.toString() and includes the name of
the class from which the object was instantiated
Introspection of class and interface membership using the instanceOf() method
The jsx3.lang.Object class works in conjunction with the other classes in the jsx3.lang
package — Class, Exception, Method, and Package —to provide these further advantages over
JavaScript 1.x:
All classes in General Interface descend from jsx3.lang.Object. Developers are encouraged to
extend the General Interface base class in application code in order to fully incorporate the
features enumerated above.
Declaring a Class
Classes are defined with the static method jsx3.lang.Class.defineClass() :
The first parameter, strName, is a string that is the fully-qualified name of the class to define,
such as "com.tibco.Widget". The defineClass() method ensures that the namespace object,
com.tibco, exists before creating the Widget constructor.
The second parameter, objExtends, is the superclass of the class to define. If null is passed,
jsx3.lang.Object is assumed. This parameter is usually provided as the constructor function of
the superclass, the fully-qualified class name without quotes.
The third parameter, arrImplements, is an array of the interfaces that the class implements. This
array can be empty or null.
The fourth parameter, fctBody, is a function that defines the contents of the class. The
defineClass() method executes this function exactly once after it has handled the details of the
Copyright © TIBCO Software Inc. All Rights Reserved.
170
defineClass() method executes this function exactly once after it has handled the details of the
JavaScript 1.x prototype inheritance implementation. The defineClass() method passes two
parameters to fctBody. The first parameter is the constructor function of the newly defined
class. The second parameter is the prototype object of the class. This is simply a syntactical
shortcut that allows for the following concise idiom:
jsx3.lang.Class.defineClass(
"com.tibco.Widget",
jsx3.lang.Object,
// Object is implicit so this parameter could be null
//in this case
[jsx3.util.EventDispatcher],
function(Widget, Widget_prototype) {
// define class members in Widget
// define instance members in Widget_prototype
}
);
There are four types of members that can be included in the class definition: static fields, static
methods, instance fields, and instance methods. Each of these types is introspectable with
methods of the jsx3.lang.Class class. Static members are declared by defining fields of the
class constructor. Continuing the preceding code example:
Static members are globally available using the fully-qualified name of the member, such as
com.tibco.Widget.getWidgetBySerial(). The same member can be referenced with
Widget.getWidgetBySerial() within the class declaration function, because com.tibco.Widget is
aliased as Widget inside the function. Unlike in Java, static members are not accessible through
instances of a class (that is, aWidget.SERIAL is undefined).
Instance members are declared by defining fields in the prototype field of the class constructor:
All classes must define a special instance method called init(). The defineClass() method
throws an exception if the init() method isn't declared in the class declaration function. The
init() method is effectively the constructor function. However, the defineClass() method
actually creates the class constructor so the developer has no way of customizing it. Instead, the
Copyright © TIBCO Software Inc. All Rights Reserved.
171
actually creates the class constructor so the developer has no way of customizing it. Instead, the
generated class constructor simply calls the init() method passing all the parameters that were
passed to the constructor. Here is the init() method for the Widget class:
Widget_prototype.init = function(name) {
this.name = name;
this.serial = Widget.SERIAL++;
};
Class-Like Constructs
The jsx3.lang package defines three class-like constructs— Class, Interface, and Package.
These constructs are not exactly equivalent to their Java/C++ namesakes.
Classes
Classes have the following characteristics:
Interfaces
Interfaces have the following characteristics:
Packages
Packages have the following characteristics:
Unlike in Java, General Interface interfaces may contain concrete instance methods. When a
class implements an interface, the instance methods of the interface are mixed into the class. A
mixed in method overrides a method of the same name inherited from the superclass but
Copyright © TIBCO Software Inc. All Rights Reserved.
172
mixed in method overrides a method of the same name inherited from the superclass but
doesn't override a method defined in the implementing class or mixed in from an interface
coming earlier in the arrImplements parameter to the Class.defineClass() method.
Classes, interfaces, and packages can "contain" classes/interfaces. Consider the following code
assuming that the class com.tibco.Widget.Encoding is defined:
// returns [com.tibco.Widget.Encoding]
jsx3.lang.Class.forName("com.tibco.Widget").getClasses();
Introspection
Once a class, interface, or package has been defined as described above, it's introspectable.
There are a few ways to get a handle to an instance of jsx3.lang.Class or jsx3.lang.Package :
Consult the API Documentation for all the methods of these classes that can be used to
introspect their contents.
Exceptions in JavaScript
Exceptions in General Interface
Exceptions and the Call Stack
When to Use Exceptions
Exceptions in JavaScript
Like many other programming languages, JavaScript provides for throwing and catching
exceptions. JavaScript supports the standard try...catch...finally statement:
try {
doSomething();
} catch (e) {
window.alert(e.description);
} finally {
cleanUp();
}
JavaScript also supports the throw statement. Any type of object can be thrown:
throw "error!";
throw {name:"anError", description:"an error occurred"};
The browser creates and throws errors under certain circumstances. For example, trying to
access a field on a variable that is undefined will raise an error. Trying to call a function that
does not exist also raises an error. These types of exceptions can also be caught with the
try...catch statement.
When an exception is raised and isn't caught, the current call stack is unwound and the browser
receives an error event. Execution of JavaScript code continues when the next stack is created
by a timeout event or by user interaction.
General Interface defines the jsx3.lang.Exception class, which extends jsx3.lang.Object and
is the superclass of all General Interface exceptions. This base class is stack aware, which means
that it stores the call stack at the point where it was created. By using and/or extending
jsx3.lang.Exception, you can take advantage of some features of exceptions that exist in more
advanced languages such as Java.
Several methods in the General Interface Framework throw exceptions to communicate to the
caller that an error has occurred. Note that some classes, such as jsx3.xml.Document, fail silently
Copyright © TIBCO Software Inc. All Rights Reserved.
174
caller that an error has occurred. Note that some classes, such as jsx3.xml.Document, fail silently
by storing error information in instance fields rather than throwing exceptions. General
Interface Framework methods that throw a General Interface exception are documented in the
API Documentation (Help>API Documentation). Such methods should be surrounded by a
try...catch block to prevent the exception from reaching the top of the call stack. Because
exceptions in JavaScript aren't checked as they are in Java, if a method that throws an exception
isn't surrounded with a try...catch block, it's not a compilation error.
try {
doSomething();
} catch (e) {
// e may be a native browser Error object or an instance of
// jsx3.lang.Exception thrown by application or framework code
var ex = jsx3.lang.NativeError.wrap(e);
window.alert(ex.printStackTrace());
}
Finally, in General Interface Builder and when error trapping is enabled in running General
Interface applications, any error that reaches the top of the stack and the browser is routed to
the General Interface logging system. The exception will be sent to the global logger,
jsx3.util.Logger.GLOBAL, with severity ERROR.
Unfortunately, in Internet Explorer, the native exception class does not store stack information.
Therefore, an instance of jsx3.lang.NativeError only contains the stack up to the point when it
was created, not up to the point where the error it wraps was raised.
The one exception to this is when a native error reaches the top of the call stack. In that
particular case, the General Interface logging system does have access to the entire stack up to
the function where the error was raised. This is problematic from the point of view of a
developer, however, because the choice is between maintaining the stack by catching an error
but losing information about how that error was created and seeing the full stack trace of the
error but not being able to recover from the error.
One possible development practice to deal with this shortcoming of Internet Explorer is to
include fewer try...catch statements in the early stages of developing an application and
including more as the quality of the code improves.
The benefit of using exceptions usually increases with the size of the application. Exceptions
require the developer to define the success and error conditions of methods and require the
calling code to handle both possibilities. Code therefore can have fewer bugs and be clearer and
more robust than code that uses another error reporting mechanism or ignores error conditions
altogether. Additionally, exceptions help with the principle of failing early. In general, it's better
to fail (raise an exception) at the first sign of trouble when the cause of the failure is
well-known. Otherwise errors might cascade to other parts of a program where they are harder
to diagnose.
Overview
Running JSXDOC
Overview
JSXDOC is a program that creates API documentation from JavaScript source files. JSXDOC
parses JavaScript syntax and a comment metadata syntax to produce the structured
documentation. JavaScript source files that are run through the compiler must conform to the
JSXDOC syntax. JSXDOC can export documentation as XML or HTML files.
Syntax
The supported documentation syntax is similar to javadoc syntax. Relevant comment blocks are
range comments that begin with /** and are placed immediately before the member that they
describe. You can document packages, classes, interfaces, methods, and fields. Methods and
fields are defined in the class, interface, or package whose definition most closely precedes it. (It
is an error to define a method or field in a location where there is no such class context).
The documentation compiler parses JavaScript to determine what type of member a comment
block documents. The member declaration that follows the comment block (or that is specified
with the @jsxdoc-definition tag) must match one of the following patterns.
prototype.NAME = x; Defines an instance field. The field name is determined from the
declaration.
NAME: x - Defines an instance field (as in the previous declaration). The field name is
determined from the declaration.
x.NAME = x; Defines a static field. The field name is determined from the declaration.
Documentation Blocks
Documentation blocks can begin with a free-form paragraph that describes the member. HTML
tags are allowed in this and most other text blocks. HTML entities must be escaped in order to
be interpreted as plain text. The type declaration of a field, if documented, must precede its
description.
The param, return, and throws tags, and the field description, support optional type
information. Types are always documented between curly braces, {}. A type can be any valid
JavaScript identifier or package+identifier. A type whose class is included in a compilation will
be linked automatically to the definition of that class. The following constructs are also
supported, both alone and in most combinations.
Tags
Tags begin on a new line and begin with the @ character. The following tags are supported.
@public, @package, @protected, @private Sets the access level of the documented
member. If a documentation comment exists the default is public, otherwise the default
is private.
@version STRING Documents the version of the member.
@since STRING Documents the version when the member was introduced.
@deprecated [STRING] Documents that the member is deprecated and adds an optional
description of the deprecation.
@author STRING Documents the author of the member. Any number of author tags may
be documented.
@param NAME [{TYPE}] STRING Documents a method parameter. Any parameters that are
not explicitely documented with this tag are parsed from the definition and included
(without type or description) in the compiled documentation.
@param {TYPE} NAME STRING This is an alternative supported syntax of a method
parameter.
@param-package and @param-private You can use these to set the access level of a
particular parameter so that it does not show up in the compiled documentation.
@return [{TYPE}] STRING Documents the return type of a method and adds a description
to the returned object. The type is optional. Method that have no non-empty return
statements should not include this tag.
@throws [{TYPE}] STRING Documents an exception type that a method may throw and
the conditions under which it is thrown.
@final Documents that a method should not be overridden or a class should not be
Copyright © TIBCO Software Inc. All Rights Reserved.
178
@final Documents that a method should not be overridden or a class should not be
extended. The JavaScript language does not enforce this documentation construct.
@static Documents a field or member as static even when the member declaration is not
understood by the parser to be a static declaration.
@protected Documents that a method or field should only be used from within the class
that defined it or one of that class's subclasses. The JavaScript language does not enforce
this documentation construct.
@abstract Documents that a class is abstract. Methods defined with j
sx3.lang.Method.newAbstract() are automatically recognized as abstract. Any class or
interface with an abstract member is also automatically recognized as abstract.
@native Documents that this member is defined by the JavaScript engine or host
browser.
@see STRING Adds a See section to the documentation of this member. There are several
supported formats for the STRING argument:
"TEXT" Inserts a text label.
<a href="URL">TEXT</a> Inserts an HTML link to URL.
#LOCAL_FIELD [LABEL] References a field in the same class with optional label
LABEL.
#LOCAL_METHOD() [LABEL] References a method in the same class with optional
label LABEL.
pkg.Class#FIELD [LABEL] References a field in another class, pkg.Class, with
optional label LABEL.
pkg.Class#METHOD() [LABEL] References a method in another class, pkg.Class,
with optional label LABEL.
@jsxdoc-definition JS_DEFINITION In the case that a documentation block cannot appear
immediately before the member definition, this tag can be used to specify the member
definition. This tag can also be used to tell the compiler what member the comment
block describes in the case that members are not defined according to the JavaScript
syntax that the compiler expects.
@jsxdoc-category CLASS In the case that the members of a package, class, or interface are
defined across multiple files or sections of files, this tag can be used to indicate that tags
following it belong to CLASS but without redefining CLASS in the process.
Example
The following code example declares a JavaScript class, jsx3.util.list, and includes many of
the JSXDOC tags.
/**
* Adapted from <code>jsx3.util.List</code>.
* <p/>
* An object-oriented version of the built-in JavaScript <code>Array</code> class.
* <p/>
* Note that methods such as <code>indexOf</code> and <code>remove</code> compare
objects
* with the strict equality operators (<code>=h1. </code> and <code>!</code>\).
Therefore, for the purposes of this
* class <code>1</code> and <code>"1"</code> are not equal.
*
* @since 3.2
*/
jsx3.Class.defineClass('jsx3.util.List', null, null, function(List, List_prototype) {
/**
* {int} A final static field.
* @final
*/
List.STATIC_FIELD = 5;
/**
* If <code>a</code> is already an instance of this class, this method returns
<code>a</code>.
* If <code>a</code> is an array, this method returns a new List instance backed by
<code>a</code>.
* @param a {Array|jsx3.util.List}
* @return {jsx3.util.List}
* @throws {jsx3.IllegalArgumentException} if <code>a</code> is not a list or
array.
*/
List.staticMethod = function(a) {
if (a instanceof List) {
return a;
} else if (a instanceof Array) {
return new List(a, true);
} else {
throw new jsx3.IllegalArgumentException("a", a);
}
};
/**
* The instance initializer. Creates a new list.
* @param a {Array}
* @param-private bLive {boolean}
*/
List_prototype.init = function(a, bLive) {
if (a instanceof Array) {
this._src = bLive ? a : a.concat();
} else {
this._src = ;
}
};
/**
* @return {int}
*/
List_prototype.size = function() {
return this._src.length;
};
/**
* Varargs example.
* @param o {Object...}
*/
List_prototype.add = function(o) {
this._src = this._src.concat(arguments);
};
/**
/** @private */
List._privateMethod = function(a) {
return a;
};
});
Running JSXDOC
JSXDOC is distributed with the source distribution of General Interface as a Java class with an
Ant task interface. The easiest way to run JSXDOC is via the Ant interface.
To get started:
1. Make sure that Java 1.5+ and Ant 1.7+ are installed. Downloads are available at
http://java.sun.com and http://ant.apache.org.
2. Download the GI source distribution from at http://www.generalinterface.org. Unzip it
to GI_SRC.
3. Run the command ant package in the directory GI_SRC/build/tools. This creates a
jsx-tools.jar file in same directory. The JAR file contains the JSXDOC program and
Ant task.
4. Copy jsx-tools.jar and the following files into a new directory, JSX_RUN.
GI_SRC/build/tools/lib/javacc/bin/lib/javacc.jar
GI_SRC/build/tools/lib/jaxen/jaxen-1.1.jar
GI_SRC/build/tools/lib/dojo/jsl.jar
GI_SRC/build/tools/lib/xml/xalan-serializer-2.7.jar
GI_SRC/build/tools/lib/saxon/saxon8.jar
GI_SRC/build/tools/lib/saxon/saxon8-dom.jar
GI_SRC/build/apidoc/
<target name="init">
<property file="build.properties"/>
</target>
<path path="saxon8-dom.jar"/>
</path>
<delete dir="${tmp.dir}"/>
</target>
</project>
7. In the same directory, create the Ant build.properties file from the following template.
The build.properties file allows you to configure the Ant build process without
modifying the build.xml file.
# The title of the compiled API documentation
gi.apidocs.title = My Library®
# The title of the compiled API documentation, XML-escaped
gi.apidocs.title.esc = My Library&reg;
# The copyright of the compiled API documentation, XML-escaped
gi.apidocs.copyright = Copyright &copy; My Company
xsl.dir = apidoc
js.dir = src
tmp.dir = tmp
doc.dir.xml = doc/xml
doc.dir.html = doc/html
The namespace of a General Interface application is the name of the global JavaScript variable
that is set to the instance of jsx3.app.Server representing the application. Custom application
JavaScript code usually references this variable extensively since the server provides access to
the General Interface DOM and local data cache, among other things.
The namespace of a General Interface application must be unique for each application deployed
in a single web page. If a namespace collision occurs, the code of only one of the applications
has access to its jsx3.app.Server instance. The other applications will likely break. Namespaces
should always be checked for uniqueness before creating a deployment page with multiple
General Interface applications.
A good way to ensure namespace uniqueness is to use the reverse domain naming convention
Copyright © TIBCO Software Inc. All Rights Reserved.
185
A good way to ensure namespace uniqueness is to use the reverse domain naming convention
when choosing your application namespace. For example, you could use com.tibco.gi.App1
and com.tibco.gi.App2. This ensures that your applications won't conflict with General
Interface applications from other organizations.
com.tibco.gi.App1.getJSXByName("textbox");
The DOM index on name tracks only one node per name. Therefore, the getJSXByName()
method only returns a predictable value for names that are unique over the entire application.
The jsx3.GO() method is a shortcut for fetching a DOM node by name or ID. The jsx3.GO()
method has access to all loaded General Interface applications and searches all of them for a
DOM node of the given name. The jsx3.GO() method is therefore slower than getJSXByName()
Copyright © TIBCO Software Inc. All Rights Reserved.
186
DOM node of the given name. The jsx3.GO() method is therefore slower than getJSXByName()
and allows one application to affect another application. Only use jsx3.GO() in the General
Interface Builder JavaScript Console where brevity is more important than accuracy.
Application code should not use jsx3.GO.
jsx3.GO("textbox");
Access to the application local data cache is provided by the getCache() method in the
jsx3.app.Server class. The following code fetches a cache document from the App1
application:
com.tibco.gi.App1.getCache().getDocument("docId");
In general, applications should not declare global JavaScript functions. The following code
defines a global JavaScript function:
function doTest() {
return 1;
}
This is equivalent to declaring the function as a member of the global window object:
window.doTest = function() {
return 1;
};
Since all General Interface applications deployed in the same web page share the same global
window object, any code placed in it isn't private to a particular application. If two different
applications define a global doTest() method, one version is overridden by the other and one
application will probably break.
To avoid any naming collisions in function and variable names, all code should be placed in
packages. Using the reverse domain naming convention is a good choice for avoiding collisions.
A package is essentially a nested data structure descending from the window object. The
following code creates the com.tibco.gi package and defines the doTest() function in it.
However, this code has a bug in it, because it will destroy any previously defined package
descending from window.com, such as com.tibco.porta l. With this technique for creating a
package, the nested objects should only be created if they do not already exist.
The jsx3.lang.Package class simplifies the task of creating a package greatly with the
Copyright © TIBCO Software Inc. All Rights Reserved.
187
The jsx3.lang.Package class simplifies the task of creating a package greatly with the
definePackage() method. The following code also defines the doTest() function in the
com.tibco.gi package but without the bug in the previous code sample:
jsx3.lang.Package.definePackage("com.tibco.gi", function(gi) {
gi.doTest = function() {
return 1;
};
});
Since JavaScript packages can be named using the reverse domain naming convention, they are
very safe from naming collisions.
For more information, see the jsx3.lang. Package in General Interface API Reference.
General Interface Framework, the General Interface runtime, provides a jsxhelpid property for
implementation of context-sensitive help in your General Interface applications. The jsxhelpid
property is a unique string identifier that can be set in the Properties Editor palette (Help ID) in
General Interface Builder or set programmatically using the jsx3.app.Model.setHelpId()
method.
When a help ID is specified for a component, the user can launch context-sensitive help by
pressing hot keys, which are system- and locale-dependent. The application automatically
listens for the key event and determines the closest ancestor of the object receiving the key
event that has a help ID. If an ancestor exists, the key event is canceled and the application,
which is the Server object, publishes an event of subject jsx3.app.Server.HELP.
Application code can register for the HELP event from the application's Server object and
perform custom code appropriate for the application, such as launching an external web page
or opening a custom-built General Interface help viewer.
Help APIs
The help APIs include the following:
1. Set help IDs for areas of the user interface, such as palettes and dialogs:
Set the Help ID property in the Properties Editor palette of General Interface
Builder.
Set the help ID programmatically using the jsx3.app.Model.setHelpId() method.
2. Subscribe to the HELP event using jsx3.app.Server.HELP ("event subject_").
For example, the next example demonstrates how to send a message to an alert when a server
publishes a HELP event. The JavaScript package is eg.app and the server is eg.app.APP, as
shown in the following example.
eg.app.APP.subscribe(jsx3.app.Server.HELP, eg.app.onHelp);
eg.app.onHelp = function(objEvent) {
objEvent.target.alert("Help", " ")
};
Loggers
Handlers
A handler, which receives log messages from the loggers it's registered with, defines what to do
with a logging message. A handler can output messages in a specified format to various
destinations, such as to memory, system log, console, files, and so on. In some cases, a handler
might ignore messages.
A logger is identified by its unique name. All logger instances exist in an inheritance tree and
are descendants of the global logger. Inheritance is organized by name with the dot (".")
character defining levels of the tree. For example, a logger named com.tibco inherits from com,
which inherits from the root logger, global. Loggers are typically given names based on the
package or class name of the component. Handlers must also have unique names. Because
handlers don't inherit from other handlers, names can be much simpler and do not need to be
based on inheritance.
Log Levels
Each logger has a log level associated with it. Log levels control which messages pass through
the logger. A logging message also has a level associated with it. Only a message with a level
equal to or more severe than the level specified for the logger passes through the logger. The
levels defined in the system are, in order of decreasing severity, — FATAL, ERROR, WARN, INFO,
DEBUG, and TRACE.
In the following example, mylogger is assigned a level of DEBUG. This logger only forwards
messages of level FATAL, ERROR, WARN, INFO, and DEBUG to the appropriate handlers. All TRACE
messages are ignored.
If a log level isn't specified, the logger inherits the log level of its parent logger, such as the
global logger. In this example, mylogger2 inherits log level INFO from its parent logger, global.
Only FATAL, ERROR, WARN, and INFO messages are forwarded by mylogger2 to the registered
handlers.
Handlers, like loggers, can also define a minimum level of message that they handle. In the
following example from the logging system configuration file (logger.xml), appMonitor1 has
been assigned a level of ERROR. This handler only outputs messages of a level equal to and
more severe than ERROR, even though the logger it is registered with, global, forwards all
messages of level INFO and more severe.
You can also edit logger.xml, as well as create a custom logging system configuration file. See
Creating a Custom Logging System Configuration File.
Memory Handler
The memory handler stores a rotating cache of logging messages in memory. Note that some
features of the General Interface Builder IDE require this handler. If it's not available, they
won't function properly.
bufferSize : The size of the buffer and the number of records the buffer holds until it
begins discarding old ones.
bufferSize : The size of the buffer and the number of records the buffer holds until it
begins discarding old ones.
format : The format of the delivered message. For definitions of formatting tokens, see
jsx3.util.Logger.FormatHandler in General Interface API Reference.
beepLevel : The message level that triggers a sound when printed to the System Log
palette in the IDE. For more information, see Enabling Sound for Messages.
For sound to work properly, Firefox requires a plug-in that can play .wav
files.
format: The format of the delivered message. For definitions of formatting tokens, see
jsx3.util.Logger.FormatHandler in General Interface API Reference.
The alert handler is registered with the jsx3.util.Logger logger to capture any errors not
handled correctly by the other handlers.
The logging system configuration file provides a template for creating an application monitor
handler. By default, the application monitor is disabled. For more information, see Creating an
Application Monitor Handler.
serverNamespace: The value must match the application namespace to associate the
application monitor with the application. The namespace is specified in the Namespace
field on the Deployment panel of the Project Settings dialog.
Copyright © TIBCO Software Inc. All Rights Reserved.
194
Global Logger
The global logger is the ancestor of all other loggers. Custom handlers and application monitor
handlers can be registered with the global logger.
Any logger can have the following attributes and nested entities:
Logger attributes:
name : The unique name of the logger.
level : Controls which messages pass through the logger. If this attribute is
omitted, all log levels pass through the logger. See Log Levels.
Nested entities — handler-ref:
name : The name of the handler registered with the global logger. Custom handlers
and application monitor handlers can be registered here.
Handler Attributes
Handlers can include the following attributes:
list of statically loaded classes, see General Interface Framework Classes. Use the lazy or
require attribute but not both.
level : Controls which messages the handler outputs. See Log Levels.
prints the following line to the System Log palette if the default logging file is used:
When a message is sent to the logging system, it is sent through a logger instance, which has a
unique name and can also have a specified log level. A logging message also has a level
associated with it. If the message's log level matches or exceeds the logger log level, the logger
forwards it to the registered handler. For more information, see Log Levels.
For more precise control of the logger and level of a logging message, the Logger class can be
used. The static Logger.getLogger() method returns a logger instance of the given name. Note
that loggers are instantiated dynamically and the getLogger() method always returns a logger
instance, even if it's not specified in the logging system configuration file.
For example,
The Logger class defines an instance method named for each level:
There are several other methods of the Logger class that are useful for logging. For more
information, see General Interface API Reference.
It is best programming practice to design logging messages as a permanent part of the source
code. It's useful to partition the logging messages that an application or library creates by
category. Each category corresponds to a unique logger instance. One practice is to define a
logger for each class in a system with a name equal to the fully qualified class name. Another
common practice is to divide the system into a set of subsystems, each with its own logger.
Logging messages can be stripped from code before the code is deployed. This is necessary
under logging systems that use standard out, (in JavaScript) window.alert(), or some other
mechanism that is highly visible to both the developer and the user of an application.
In General Interface applications, there's no need to remove the logging messages from the
source code, because the logging system is configured through a declarative XML file. The
advantage to leaving logging messages in your code is that you can diagnose errors after
deployment. Simply modify the logging system configuration file, run the deployed
Copyright © TIBCO Software Inc. All Rights Reserved.
196
deployment. Simply modify the logging system configuration file, run the deployed
application, and determine what the errors are by viewing the logging messages.
The logging system is designed to impact the performance of General Interface applications as
little as possible. The following code is a good example of how to send a logging message
efficiently when constructing the message is expensive. The code simply checks the logger to
see whether the logging message passes the logger's level before creating and sending the
message.
View at runtime
The logging system configuration file, logger.xml, is located in the GI_HOME directory. The
default configuration file includes the following lines that declare the General Interface Builder
ide handler:
lazy="true">
value="jsx3.util.Logger.ERROR"/>
</handler>
The following lines register the ide handler with the global logger:
<handler-ref name="ide"/>
</logger>
By default, the ide handler is defined without a log level, so messages aren't filtered by level.
Because the global logger is configured with level INFO, all messages of INFO and higher are
forwarded to the ide handler and output to the System Log palette. TRACE and DEBUG messages
aren't forwarded to the handler, regardless of the handler's level.
If you add level =" WARN" as an attribute of the handler element, the System Log palette would
only display messages of severity WARN and higher, instead of INFO and higher. For example,
An application monitor has three running modes that correspond to four stages of application
development:
Off The monitor isn't configured in the logging system configuration file. This is the
default setting. This is appropriate at the beginning of application development when all
development occurs in General Interface Builder or at the end of development when the
application is stable and error-free.
On The monitor is configured in the logging system configuration file with the
activateOnHotKey property equal to false. This is appropriate when only developers are
using a deployed application, because logging messages are always visible.
Hot Key Activated The monitor is configured in the logging system configuration file
with the activateOnHotKey property equal to true. This is appropriate when a mix of
developers and users have access to an application or when an error needs to be
diagnosed in a live, deployed application.
In the following XML snippet of the logging system configuration file ( logger.xml), two
monitor handlers are created, one for each application.
require="true">
</handler>
require="true">
</handler>
If the specified handler class is not a statically loaded class, use require="true", so
the class is dynamically loaded and available when it's needed. For a list of statically
loaded classes, see General Interface Framework Classes.
<handler-ref name="memory"/>
<handler-ref name="ide"/>
<handler-ref name="appMonitor1"/>
<handler-ref name="appMonitor2"/>
</logger>
Popup blockers may interfere with application monitors, since they exist in separate
browser windows. If the monitor window does not appear as expected, verify that
popup windows aren't blocked.
A custom logging handler, which must implement the abstract Handler.handle() method, is
created by extending the jsx3.util.Logger.Handler class or one of its subclasses. This method
defines how a logging message is handled. The following implementation, which simply stores
a rotating cache of messages in memory, is from the MemoryHandler class:
MemoryHandler.prototype.handle = function(objRecord) {
this._buffer.push(objRecord);
Custom handlers are configured in the logging system configuration file just like other
handlers. Since custom handlers load after the logging system has been configured, they must
be configured with the attribute lazy="true", so that the logging system won't throw an error
on initialization if the handler class isn't loaded. Another option is to use the attribute
require="true", so the class is loaded immediately using the dynamic class loading mechanism.
jsx3.util.Logger.Handler.registerHandlerClass(
com.tibco.LogHandler.jsxclass);
Handlers may also define bean-style properties that can be configured in the logging system
configuration file. Any property element nested within a handler element defines a name-value
pair of a property of the handler. The handler class must have a bean-style setter method for
any configurable property. For example, the handler class, FormatHandler, defines the property
format, because it defines getFormat() and setFormat() methods. Therefore, any handler of a
class that is a descendant of FormatHandler can be configured with the format property.
For your convenience, a logger.xml template is provided for you in the workspace/settings
directory. Open this template, add your custom loggers and handlers, and save it to any
location with any name. When deploying the application, remember to copy this file to the web
server with the other project files.
To pass the custom logging system configuration file as a deployment parameter, add the
jsx_logger_config attribute to the script element on the page that launches the application.
The value of the attribute should be an absolute URI or the relative path from the HTML launch
page to the logging system configuration file.
jsxapppath="../workspace/JSXAPPS/samples/WSDL_Mapping_1/"
jsx_logger_config="loggers/mylogger.xml">
</script>
jsx3.util.Locale
jsx3.util.DateFormat
jsx3.util.MessageFormat
jsx3.util.NumberFormat
jsx3.app.PropsBundle
For more information on these classes, see General Interface API Reference (Help > API
Documentation).
jsx3.util.Locale
General Interface 3.2 introduced a new class, jsx3.util.Locale, which represents a locale. A
locale is a region of the world that shares a common language, writing, calendar, and so on. A
locale is represented with a locale key, such as es_ES for Spanish in Spain. See Locale Keys.
The General Interface system, jsx3.lang.System, has a locale which determines the language
and formatting of system messages. By default, the system locale is set automatically to the
locale of the host web browser. However, the locale can be changed by calling the
System.setLocale() method.
Each General Interface application, which is an instance of jsx3.app.Server, also has a locale.
The server locale determines the locale of localized GUI controls that it contains. The
application locale also determines which locale-sensitive resources are loaded into the
application.
Locale Keys
The locale key is the string representation of a locale, which includes a language or a language
and a country in one of the following formats:
ll
ll_CC
where ll is a lowercase, two letter, ISO 639 language code and CC is the optional, uppercase,
two letter, ISO 3166 country code.
General Interface leverages data from the Common Locale Data Repository to localize these
classes. The following locales from the CLDR are included with General Interface.
Arabic ar
Danish da da_DK
Finnish fi fi_FI
German de de_DE
Greek el el_GR
Hebrew he he_IL
Indonesian id id_ID
Italian it it_IT
Japanese ja ja_JP
Korean ko ko_KR
Norwegian nn nn_NO
Polish pl pl_PL
Russian ru ru_RU
Swedish sv sv_SE
Thai th th_TH
Turkish tr tr_TR
Vietnamese vi vi_VN
DateFormat
The DateFormat class formats and parses dates in a localized manner. Months and days of the
week are localized. Additionally, factory methods are available for creating formats that are
appropriate for a particular locale.
NumberFormat
The NumberFormat class formats numbers in a localized manner. Number symbols, such as the
negative sign, decimal symbol, and percent symbol, are also localized. In addition, factory
methods are available for creating formats that are appropriate for a particular locale.
MessageFormat
The MessageFormat class constructs messages from a format and various inputs. It's localized,
because it can format inputs according to both DateFormat and NumberFormat.
jsx3.app.PropsBundle
The jsx3.app.PropsBundle class handles localized loading of resources. A localized resource is
a collection of dynamic properties files that define a set of properties localized for one or more
locales. For an example of a properties bundle file, see GI_HOME/JSX/locale/locale.xml.
bundle_name.xml - the file containing the properties of the default locale and metadata
describing the locales that are available in other files. For example, locale.xml.
bundle_name.locale_key1_.xml - the file containing properties localized for locale
locale_key1. For example, locale.fr.xml.
bundle_name.locale_key2_.xml - the file containing properties localized for locale
locale_key2. For example, locale.es.xml.
The default locale file in the properties bundle should be formatted as follows:
</data>
Any other file in the same properties bundle should be formatted as follows:
<data jsxnamespace="propsbundle">
<!-- The file must define properties for the locale for which the
file is named. -->
<locale key="external_locale_key1">
...
</locale>
<!-- Optionally, the same file may also define properties for
subordinate locales. For example, if the above locale is "en"
then it could be followed by "en_US", "en_GB", "en_AU", etc.
-->
<locale key="locale_key_country1">
...
</locale>
<locale key="locale_key_country2">
...
</locale>
...
</data>
PropsBundle.getProps()
An instance of the PropsBundle class is obtained programmatically with the static factory
method, PropsBundle.getProps(). The first argument for this method is the base path of the
localized resource. In this example, it would be bundle_name.xml preceded by the path to the
directory containing the bundle. For example, path_to_bundle/locale.xml. The second
argument is an instance of jsx3.util.Locale. The factory method loads the files appropriate for
the requested locale based on the metadata contained in the default locale. For more
information, see General Interface API Reference.
Key Fall-through
The PropsBundle class provides for key fall-through. If a key isn't found in the properties file of
a particular locale, the value from the next less-specific locale is used. For example, if an
instance of PropsBundle with a locale of en_GB is queried for a key, it checks the properties of
locale en_GB. If the key isn't found, it checks en, and finally, the properties of the default locale
until a key is found.
DatePicker
TimePicker
Select
Menu
Matrix
English en
French fr
German de
Japanese ja
Korean ko
Portuguese pt
Russian ru
Spanish es
Localizing an Application
Localizing an application involves the following steps:
1. Choose File > New > Properties Bundle to open the editor.
2. Right-click the table header in the editor and choose Add New Locale.
Copyright © TIBCO Software Inc. All Rights Reserved.
207
2. Right-click the table header in the editor and choose Add New Locale.
3. Type the key for the locale in the Add Locale dialog, such as en_US for US English or es
for Spanish. For information on keys, see Locale Keys. Click OK.
4. Click each Default cell and type the value for the default language. For example, for
menu_new, type New.
5. Click each cell of the new locale column and type the value for the new locale. For
example, for menu_new, type Cree for the Spanish locale.
If a value is specified, the cell background is white. Otherwise, the inherited value from
the next less-specific locale is shown in a gray cell.
6. Save the file with the .xml extension in the jss folder of your project.
Using Properties
Any property contained in a dynamic properties file or properties bundle and loaded by an
application is available to the application in the following ways:
The Properties Editor palette also allows you to assign properties from a properties bundle file.
To enter a property from a properties bundle file, type the property key (ID) in a Value cell of
the Properties Editor palette.
Default Locale
The locale as determined by the browser may not be the most appropriate locale for an
application. If an application must always display in one locale, regardless of the user, use the
Default Locale setting in the Project Settings dialog. See Deployment Panel.
Server.setLocale() Method
In some situations, specifying a default local isn't the best solution. In the following cases, use
Server.setLocale() to set the locale:
Note that after the Server.setLocale() method is called, the state of the application may be out
of synchronization with the new locale. Call the Server.reloadLocalizedResources() method to
reload any localized properties that have already been loaded by the application. Additionally,
the view of the application may have to be repainted.
The following sample code demonstrates how to use the Server.setLocale() method.
/**
* Function is executed when user selects the language on the Tools menu.
* @param objMenu {jsx3.gui.Menu}
* @param strID {String} the CDF record ID of the execute menu record.
*/
// Reset the CDF cache of the menu since dynamic properties are used
// in the source XML file.
objMenu.resetXmlCacheData();
For example, if you want to localize a menu using the properties bundle file, you would enter
keys from the properties bundle file as the values for the jsxtext attributes, such as
jsxtext="{menu_new}".
<data jsxid="jsxroot">
<record jsxid="1" jsxtext="{menu_new\}"/>
<record jsxid="2" jsxtext="{menu_open\}"/>
<record jsxid="3" jsxtext="{menu_save\}"/>
</data>
Then, if the locale is Spanish, the following keys are replaced with the appropriate values in the
properties bundle file:
The replacement of key attributes with the property value occurs only once per XML document.
The CDF attributes that are converted automatically include: jsxtext, jsxtip, jsximg,
jsxstyle, jsxclass, and jsxkeycode. After the conversion, which occurs before the control is
painted, the original value of any key that has been converted is lost. Therefore, changing the
value of a dynamic property after the conversion doesn't change the CDF attribute value. Do
not set CDF attributes programmatically to a property key. Instead, set CDF attributes to the
property value programmatically. You can also use the CDF.convertProperties() method to
perform the conversion.
Deployment consists of configuring the application for one of the following access models:
Full console application The application runs in a dedicated browser window. The
application is launched when an end user opens an HTML or XHTML file or clicks an
application hyperlink in an existing web page.
Non-console application The application is inserted into an existing web page as a div
element and only uses a portion of the page. A web page can contain multiple General
Interface applications.
General Interface Builder provides the Deployment Utility for generating the HTML or XHTML
code for launching applications. This chapter describes how to use the Deployment Utility and
configure your application.
To launch a full console application, a launch page is required. A launch page is an HTML or
XHTML file that loads the application in a browser window. This file initializes the General
Interface environment, loads your application into the browser, and renders it to the entire web
page. You can create a new launch page or use the provided parameterized launch pages,
shell.html or shell.xhtml.
To create a page for launching a full console application, complete these steps:
1. Select Project > Deployment Utility from the General Interface Builder menu.
Copyright © TIBCO Software Inc. All Rights Reserved.
213
1. Select Project > Deployment Utility from the General Interface Builder menu.
2. Click the Browse button , to navigate to a directory, and type the launch file name, for
example launch.html or launch.xhtml. If you're creating an XHTML launch page, check
the XHTML checkbox and use the .xhtml extension. Click Save.
3. On the HTML Page panel, click the Create button to create the launch file. A new file is
created in the selected directory.
4. Close the Deployment Utility.
5. Open the launch page in a web browser.
The General Interface software initializes and your application displays. Before
proceeding, you can view the source of the HTML page that was automatically
generated.
6. Select View > Source from the browser menu to view the source of this page. The
Deployment Utility generated the following lines of HTML markup:
For XHTML files only, a DOCTYPE declaration is required before the html root
element. An XHTML namespace attribute is also required for the html element.
The div element, which provides the HTML container for your General Interface
application. You can change the style of this element by modifying its CSS
Copyright © TIBCO Software Inc. All Rights Reserved.
214
application. You can change the style of this element by modifying its CSS
properties.
<div style="position:absolute;left:0px;top:0px;width:100%;
height:100%;">
.
... script element ...
.
</div>
The script element, which loads the General Interface runtime, passes the project
path to it, and specifies how classes are loaded.
<script type="text/javascript"
src="JSX/js/JSX30.js"
jsxapppath="../workspace/JSXAPPS/MyProject/">
</script>
src="JSX/js/JSX30.js" The relative path from the web page to the General
Interface runtime file.
jsxapppath The relative path from the web page to the project directory.
7. Modify the HTML markup as needed to customize the page.
1. Select Project > Deployment Utility from the General Interface Builder menu to open the
Deployment Utility.
2. Click the Launch Link tab.
3. Copy the text in the lower pane of the tab and paste it into an HTML page.
The following template is used for launch link HTML markup:
shell.html The relative path from the web page to the parameterized application
launch page. shell.html is located in the GI_HOME directory.
jsxapppath The relative path from shell.html to your project directory.
Launch Application The text of the hyperlink for launching the application.
4. Close the Deployment Utility.
5. Modify the HTML markup as needed to customize the hyperlink. For example, change
the hyperlink text to the name of the application.
Non-console applications can be inserted into an existing web page using div elements. When
the web page is loaded, the General Interface Framework initializes. Then the General Interface
applications are loaded.
1. Select Project > Deployment Utility from the General Interface Builder menu.
2. Click the Inline DIV tab.
3. Copy the text in the lower pane of the tab and paste into an HTML page.
The following template is used for creating a div element:
<div style="width:100%;height:400px;">
<script type="text/javascript" src="JSX/js/JSX30.js"
jsxapppath="../workspace/JSXAPPS/MyProject">
</script>
</div>
The script element contains src=" JSX/js/JSX30.js", which is the relative path from the
web page to the General Interface runtime file, and jsxapppath, which is the relative path
from the web page to the project directory.
To insert multiple applications in one web page, the src attribute must be identical
and the path to the JSXAPPS directory must be the same. For a parameterized src
URI, only the attribute before the "?" needs to be identical. The query can be
different. For example, these are considered identical even though the parameters
are different. Note that the path to the JSXAPPS directory is the same, as required.
src=" JSX/js/JSX30.js?jsxapppath=../workspace_/JSXAPPS/project1_path_"and
src=" JSX/js/JSX30.js?jsxapppath=../workspace_/JSXAPPS/project2_path_". For
more information on parameters, see Deployment Parameters.
Example
General Interface Builder generates the following div elements for two of the General Interface
Builder sample applications:
<div style="width:100%;height:400px;">
<script type="text/javascript" src="JSX/js/JSX30.js"
jsxapppath="../workspace/JSXAPPS/samples/WSDL_Mapping_1">
</script>
</div>
<div style="width:100%;height:400px;">
<script type="text/javascript" src="JSX/js/JSX30.js"
jsxapppath="../workspace/JSXAPPS/samples/WSDL_Mapping_2">
</script>
</div>
When this HTML markup is inserted in an HTML page, the applications are loaded in the same
HTML page.
<div style="width:100%;height:400px;position:relative;">
<script type="text/javascript" src="/3.5/GI/JSX/js/JSX30.js"
jsxapppath="/3.5/GIApps/JSXAPPS/chart/">
</script>
</div>
<div style="width:100%;height:300px;position:relative;">
<script type="text/javascript" src="/3.5/GI/JSX/js/JSX30.js"
jsxapppath="/3.5/GIApps/JSXAPPS/WSDL_Mapping_1/">
</script>
</div>
2. Then save the config.xml file to the project folder in the JSXAPPS directory.
If the directory structure looks similar to the following figure, you would add this record to
config.xml :
Once the application directory is overridden, all URIs used in the application resolve relative to
the base directory rather than to the config.xml file.
For more information on how URIs are resolved, see URI Resolution.
General Interface is compatible with all HTTP/S web servers and requires no additional
executables to be installed, either on the server or the client.
1. Copy the following files and folders to a directory accessible to the web server. The files
can be in any location on the server.
JSX folder
The addins and prototypes folders must be at the same level as the
JSXAPPS folder to be available at runtime.
For dynamic properties files, be sure to use the .xml extension as some
servers won't recognize the .jss extension. By default, General Interface,
version 3.2 and higher, supports the .xml extension, which is the
recommended file extension. See Dynamic Properties Files. If you continue
to use the .jss extension, you might need to add a new Mime Type to the
server.
Deployment Examples
Because General Interface deployment is extremely flexible, there are few restrictions on where
your files are located on the web server. Folders and files can be nested and in different
locations. Due to the relative URI functionality introduced in General Interface 3.2, projects can
be easily renamed and moved to new locations. For more information, see URI Resolution.
In some cases, the General Interface runtime is deployed in one location by the system
administrator and developers deploy their applications to another location on the same web
server. The following example demonstrates this scenario on a UNIX machine:
The system administrator installs General Interface on the web server at this location —
/var/www/htdocs/gi/ version_number/
This directory contains:
shell.html (launch page)
JSX folder
Other appropriate files
The developer deploys the application here:
/home/username/htdocs/JSXAPPS/app1
And also installs a web page containing the application here:
/home/username/htdocs/app1/index.html
In another example, as shown in the following figure, the application launch pages, General
Interface runtime, and application are deployed to a folder called gideploy. However, each of
these is in a different folder. The launch pages are in an apps folder, General Interface is in a
gi/3.2 folder, and the deployed application is in a gihome folder.
The script element on the app1.html launch page shown in the previous figure would look like
this:
<script type"text/javascript"
src="../gi/version_number/JSX/js/JSX30.js"
jsxapppath="../gihome/JSXAPPS/app1">
</script>
To access an application in a browser on the client machine, navigate to the URL where the
application files are deployed.
For example, if the application is deployed to the URL http://www.myserver.com, the user
accesses the application by navigating to:
http://www.myserver.com/project_launch_file_path
where project_launch_file_path is the path to the HTML file for launching your application,
relative to the HTML doc root directory of the HTTP server.
Deployment Parameters
This section describes how to configure deployment for individual General Interface Builder
applications and the JSX system, which is the General Interface runtime.
For each deployment, modify the HTML script element(s) on the web page that
launches the application(s).
For each application, modify the application configuration file (config.xml).
When the deployed application is launched, deployment parameters are passed to the General
Interface runtime in the following order, with the first one taking precedence over the others:
General Interface provides several built-in parameters, such as jsxappns, jsxapploader, and
jsxapppath. Custom attributes or parameters can also be added to the script element. For
example, this mechanism can be used to communicate session information from a web server to
a General Interface application. However, all attributes beginning with jsx are reserved for
General Interface.
All attributes of the script element are deployment parameters used to configure
the application except these reserved HTML attributes — id, space, type,
charset, defer, src, and language.
For examples of how to use these deployment parameters in the script element, see the
following examples.
<div style="width:100%;height:400px;">
</div>
In this example, the application path, jsxapppath, is passed as a parameter to the General
Interface runtime file, JSX/js/JSX30.js.
<div style="width:100%;height:400px;">
<script type="text/javascript"
src="JSX/js/JSX30.js?jsxapppath=../workspace/JSXAPPS/samples/chart">
</script>
</div>
To pass multiple parameters, use an ampersand (&). This example passes the application path
and the progress bar loading as parameters.
<div style="width:100%;height:400px;">
<script type="text/javascript"
src="JSX/js/JSX30.js?jsxapppath=../workspace/JSXAPPS/MyProject&jsxapploader=0"
</script>
</div>
Deployment parameters include such settings as namespace, initial component to load, script to
run when loading, and so on. For more information on the available parameters, see File Menu.
Other deployment options, such as which add-ins to load, are automatically set in config.xml
from settings in the IDE.
Custom attributes can also be manually added to config.xml, which is located at the root of the
project. Simply open config.xml, add a new record element, and save the file. For example, you
could add a record that externalizes a constant from JavaScript code as shown here:
This value can also be queried using the jsx3.app.Server.getEnv() method. For example,
myApp.getEnv("CONSTANT1");
jsx_logger_config. Specifies the name and location of the logging system configuration
file to be used. You can create a custom logging system configuration file and specify its
location using this attribute. This is useful for monitoring and testing a deployed
application at runtime. See Creating a Custom Logging System Configuration File.
jsx_no_messages. When set to 1 , prevents JSX/locale/messages.xml from loading with
the system. This file is used for system messages and is probably not necessary for a
production deployment.
jsx_no_locale. When set to 1, prevents JSX/locale/locale.xml from loading with the
system. This properties bundle file provides all localized data to the system, including
information for NumberFormat, DateFormat, Locale, and DatePicker. This data may not be
necessary for some smaller applications. For more information, see Internationalizing
and Localizing Applications.
jsx_browsers. Overrides the default set of supported browsers. The format of this
parameter is bt={allow,warn}[,...]
where bt is the browser type returned by the getType() method in the
jsx3.lang.ClassLoader class. See jsx3.lang.ClassLoader in General Interface API
Reference. For example, to show a warning in Internet Explorer 6, modify the application
launch page as follows: <script src="JSX/js/JSX30.js" jsx_browsers="ie6=warn"/>
allow launches the application in the browser.
warn provides a warning for unsupported browsers and allows the user to
proceed.
By default, General Interface 3.5.1 and 3.6.0 load version 6 if available, then version 4 if
available, then version 3. If you need to use a different version, use these system parameters to
override the defaults.
General Interface runtime parameters are available using the jsx3.getEnv() method. For more
information on the getEnv() method, see General Interface API Reference.
As an example of configuring the runtime, you might configure the General Interface runtime
to print a value to the system log. The following example assigns a value of value1 to a General
Copyright © TIBCO Software Inc. All Rights Reserved.
226
to print a value to the system log. The following example assigns a value of value1 to a General
Interface runtime parameter named jsxprop1 :
would print the following output to the system log: The value of jsxprop1 is value1.
Using Cross-Domain GI
The cross-domain loading feature allows you to load the General Interface runtime and your
application from different security domains, increasing deployment flexibility and allowing
you to do the following:
Host the GI runtime on a content delivery network (CDN) for improved load times.
Use a single runtime installation for several General Interface applications, including
applications that are hosted on different domains. This can improve load time since the
GI runtime may already be in the browser cache.
Include General Interface applications in blogs and other management systems where
hosting files is not permitted.
Allow a system administrator to install a single instance of the General Interface runtime
to be shared across an organization to simplify application deployment for users.
In a build of GI that supports cross-domain loading all XML and XSL data file have been
converted into a JSONP-like format, which supports loading across domains.
becomes JSX/locale/messages.xml.js,
jsx3.net.Request.xdr(
"jsx:/locale/messages.xml",
"<data jsxnamespace=\"propsbundle\" locales=\"\">\n\n <locale>\n <record jsxid=\"
boot.env_reset\" jsxtext=\"Error redefining JSX environment parameter {0} from
''{1}'' to ''{2}''.\"/>\n <record jsxid=\"boot.class_err\" jsxtext=\"Could not load
class {0}.\"/>\n <record jsxid=\"boot.class_ex\" jsxtext=\"Error loading class {0}:
{1}\"/>\n <record jsxid=\"boot.class_undef\" jsxtext=\"Loaded JavaScript file {0} but
class {1} was not defined.\"/>\n ... ");
This conversion is completely automated by the build process, which uses the new
JsEncodeTask task to compile the XML/XSL resources. The task is turned off by default to avoid
some code and data bloat. To enable it you must set the build.gi.xd build property to true,
either in build/user.properties or on the command line:
If you want to host your application on a separate domain as well, you must process the XML
and XSL resources in your application in a similar manner. You can do so using the same Ant
task that General Interface uses. There is also a command line interface for the encoder that
comes with the General Interface source distribution:
$> cd WORKSPACE/JSXAPPS/myApp
$> find . -name "*.xml" -or -name "*.xsl" \| xargs \
sh GISRC/build/tools/bin/jsencode.sh -user ../
Deployment
When deploying an application cross-domain you must modify the GI launch page to indicate
the domains from which resources should be loaded in the cross-domain manner. Consider the
following example:
<script type="text/javascript"
src="http://cdn.host.com/gi/3.9.0/JSX/js/JSX30.js"
jsxapppath="http://apps.example.com/JSXAPPS/myApp/"
jsxxd="http://cdn.host.com/ http://apps.example.com/">
The two URLs in the jsxxd attribute indicate the cross-domain sites. Any resource whose path
begins with one of these prefixes will be assumed to exist in the JSONP-like syntax and will be
loaded in the cross-domain manner.
Synchronous Loading
Since the introduction of the Asynchronous Modular Platform in Release 3.7, General Interface
relies less and less on synchronous loading. Some public APIs still trigger synchronous loading,
however. These APIs are still available to use in applications, but they will not work if you
deploy the GI runtime or your application cross-domain as described above. This is because the
JSONP technique for cross-domain data access works only asynchronously.
The following are examples of synchronous APIs. You must not use any of these in a
cross-domain deployment.
jsx3.require()
jsx3.net.Request.send() (when open() is called with bAsync=false)
jsx3.app.Model.load()
jsx3.xml.Document.load()
jsx3.app.Cache.getOrOpenDocument()
jsx3.lang.ClassLoader.loadJSFileSync()
XML URL (of jsx3.xml.Cacheable) when XML Async is false
Persistence = Referenced (not Referenced Async)
In addition, dynamic class loading relies on synchronous loading. Dynamic class loading occurs
when an application loads a component file and one or more of the classes used in the
component file is not already loaded. There are several possible workarounds to dynamic class
loading:
Use a custom build of GI that pre-loads all GI classes that the application uses.
Use the AMP architecture and plug-in pre-requisites to declare the class requirements of
each plug-in.
Use the new 3.9 method jsx3.requireAsync() before calling Model.loadXML().
For more information on dynamic class loading and a list of statically loaded General Interface
classes, see Class Loading in General Interface.
At General Interface application initialization, General Interface first loads a version of jsx.js
appropriate for the host browser. The jsx.js file is located in a browser-specific directory, such
as GI_HOME/JSX/js/fx, GI_HOME_/JSX/js/ie6, and GI_HOME/JSX/js/ie7. The jsx.js file contains
the statically loaded framework classes, such as classes in the jsx3.lang package. After jsx.js
is loaded, subsequent classes are loaded as needed using dynamic class loading. Dynamic class
loading loads classes individually by loading the JavaScript files that define them.
Because dynamic class loading is both synchronous and serial, loading multiple classes at the
same time can degrade the performance of a General Interface application, especially when
running over HTTP. The typical uses for dynamic class loading, such as loading the
jsx3.gui.Matrix GUI class when a component file loads, almost ensure that degradation of
performance will occur. Loading the jsx3.gui.Matrix class causes several classes to be loaded
at the same time including jsx3.gui.Matrix.Column, jsx3.gui.Form, and several others.
The General Interface Load Performance Optimization script is not included in the
Enterprise Edition.
Deciding which classes to include in a custom General Interface build requires an iterative
process. First, run the General Interface Load Performance Optimization script with one set of
classes and test the performance of the application. Then run the optimization script again with
another set of classes and compare the performance to the first run.
If you want to eliminate dynamic class loading, you should include every class that your
application uses. Depending on how your application is structured, classes might be loaded
that are only required by rare usage patterns. Therefore, the best solution might be to include
only the classes needed to load the application to its first interactive state.
Set Up Requirements
Before you can create a custom build, you need the following:
Quick Steps
Complete these steps to create, test, and deploy a custom General Interface build with the
General Interface Load Performance Optimization script:
231 a.
b. Modify the path of the src attribute on the launch page or in the launch link to
point to the deployment directory.
4. Test the application performance, modify the optimization script as needed and rerun it,
and redeploy to test again.
1. Create a new deployment directory for each customized build you want to create, such
as gideploy1.
2. Copy the following files and directory from the General Interface installation directory
into each new deployment directory:
JSX/ directory
jsx3.gui.window.html
jsx3.gui.window.xhtml
logger.xml
shell.html
shell.xhtml
3. Copy the General Interface optimization script, GI_HOME/util/gi-merge.sh, to the same
file system drive as the new General Interface deployment directories you just created.
To create customized builds for multiple General Interface applications, you need to
create a deployment directory for each application. For example, if you are creating
custom builds for three applications, you would create three deployment directories,
such as gideploy1, gideploy2, and gideploy3.
1. Open the gi-merge.sh script in a text editor. In the Professional Edition the script is
located in GI_HOME/util/.
2. Specify which classes to include in the custom build. To include a class in the custom
build, set the class variable to 1 as described below.
The gi-merge.sh file defines a variable for each optional class. Each variable name is the
fully-qualified class name with periods ( . ) replaced with underscores ( _ ). For example,
Copyright © TIBCO Software Inc. All Rights Reserved.
2.
232
fully-qualified class name with periods ( . ) replaced with underscores ( _ ). For example,
the jsx3.gui.Matrix class would be jsx3_gui_Matrix in the gi-merge.sh file.
When you run the optimization script, classes with the variable set to 1 are included in
the custom build. The script automatically resolves dependencies between classes. For
example, if you include the jsx3.gui.Button class, the jsx3.gui.Form class is also
included because Button implements Form. Any classes that are set to 0 and that aren't
required by an included class are excluded.
The following example shows a code snippet from a sample optimization script file.
Classes with a variable of 1, such as jsx.gui.Form, jsx.gui.Heavyweight, and so on, are
copied to the custom build.
. . .
jsx3_gui_Dialog=0
jsx3_gui_Form=0
jsx3_gui_Grid=0
jsx3_gui_HotKey=1
jsx3_gui_Image=1
jsx3_gui_ImageButton=1
jsx3_gui_LayoutGrid=1
jsx3_gui_List=0
jsx3_gui_Matrix=1
. . .
gideploy1/JSX/js/fx/jsx.js.orig
gideploy1/JSX/js/ie6/jsx.js.orig
gideploy1/JSX/js/ie7/jsx.js.orig
To run and test the optimization script, complete the following steps:
3. Enter the command to run the customized optimization script from the General Interface
deployment directory.
Because the optimization script modifies files in the JSX directory, always
run the optimization script on each deployment directory, not on the
General Interface installation directory.
The following example shows how to run the command in a Linux shell environment.
$ sh /path_to_tool/gi-merge.sh
After running the optimization script, output similar to the following is printed to the
command line and the listed classes are merged with the classes in the jsx.js files in the
specified deployment directory.
In this example output, jsx3_gui_Matrix is set to 1:
4. Deploy the custom build and test the performance of your application with the new
customized build. See Deploying Custom Builds.
If you're not satisfied with the results, continue to modify the optimization script, rerun the
optimization script, and test the application performance until you're satisfied with the results.
1. Copy the new deployment directory and the General Interface application to a web
server. For more information, see Deploying Applications.
2. Create a deployment launch page for the application using the General Interface Builder
Deployment Utility (Project > Deployment Utility).
3. Modify the path in the src attribute of the script element on the launch page and verify
that the application path value (jsxapppath) is correct as shown in the following
examples, where deploy_dir represents the relative path from the web page to the
custom General Interface deployment directory.
<script type="text/javascript" src="deploy_dir/JSX/js/JSX30.js"
jsxapppath="../JSXAPPS/MyProjectDir/"></script>
<a href="#" onclick="window.open('deploy_dir/shell.html?jsxapppath=
../JSXAPPS/MyProjectDir','','toolbar=no,location=no,
directories=no,status=no,menubar=no,scrollbars=no,
resizable=yes,width=800,height=600,top=0,left=0');">
Launch Application</a>
4. Use the application launch page to run the deployed application and test the
performance.
For example, to launch your application using shell.html as the launch page, enter a URL
similar to the following in the browser:
http://web_server/deploy_dir/shell.html?jsxapppath=../JSXAPPS/MyProjectDir
where web_server is the address of the web server, such as localhost:8080 or mywebserver.com,
deploy_dir is the deployment directory on the web server, and MyProjectDir is the application
project directory.
This chapter describes the Asynchronous Module Platform (AMP) and its features.
About AMP
Extension Point Contract and Processing
AMP Applications and Built-In Extension Points
Plug-ins with Extensions and Extension Points
Application Techniques and Utilities
About AMP
The Asynchronous Modular Platform (AMP) is a General Interface framework for building
modular and high-performing enterprise-sized General Interface applications. AMP is an
optional part of General Interface and is packaged as an add-in. AMP provides the libraries and
templates that allow you to easily create extensible and loosely-coupled application
components and combine them into a working whole. The design of AMP is inspired by the
Eclipse plug-in architecture.
AMP Capabilities
This section describes common pitfalls of General Interface application development and how
AMP helps overcome them to improve code quality and manageability.
Component Files
Component files that are unnecessarily large often contain many objects that are initially
invisible and may only become visible during uncommon use cases.
AMP helps manage component files so that they do not burden the overall code base. From the
beginning of application development, AMP encourages decomposition of applications into
constituent parts.
AMP makes working with asynchronously loaded resources as easy as working with
synchronously loaded ones. By using asynchronous resource loading, developers can avoid the
performance problems associated with dynamic class loading and synchronous resource
loading. AMP also enforces asynchronous behavior by providing only asynchronous APIs.
Code Components
Large, successful applications generally use a publish-subscribe pattern to notify application
components of a change in application state. Unfortunately, this paradigm typically requires a
great deal of boilerplate code, plus careful attention to components as they are added or
removed from the application.
AMP allows you to define these types of dependencies declaratively in XML, thereby
significantly reducing the amount of required boilerplate code.
Copyright © TIBCO Software Inc. All Rights Reserved.
236
Application Extensibility
It is common for large applications to lack extensibility features. Extending this type of
application typically involves both coding the extension and modifying the application. If such
an application is extensible, it is because the developer has spent considerable effort to design
an extensible framework.
AMP provides a modular framework that is engineered around the needs of extensible General
Interface applications. The AMP infrastructure encourages and when appropriate, enforces, the
design of application components according to well-defined interfaces that you can extend in
the future without modifying the application.
Testing
In most application development environments, special care is required to build applications
that can be easily tested. Because developers are usually pressed to complete development
quickly, they may employ large, monolithic components, and create ad-hoc frameworks that
are not designed with testing in mind.
AMP addresses testing concerns by encouraging developers to create modular components and
by offering an application framework with generous log coverage and benchmark statistics.
Because extension points and extensions are declared in XML, the basic form of the contract
must be defined in XML. Significant flexibility is permitted when augmenting the basic pattern.
The most common way of processing extensions is to use the processExts() method of the
jsx3.amp.ExtPoint class. The following example uses the onLoad() method of a subclass of
jsx3.amp.PlugIn.
CustomPlugIn.prototype.onLoad = function() {
The processExts() method implements a visitor pattern. The parameter to the method is a
function that is called once for every child element of the XML declarations of every extension
to the extension point.
<extension-point id="xp1">
<!-- This extension point expects extensions to have one or
more child elements of name "item." Each <item/> must
declare a unique id attribute. -->
</extension-point>
It is a good practice to document the contract of the extension point with its declaration using
an XML comment, as shown above, or with arbitrary nested XML. Any nested XML is allowed,
provided that it is not in the AMP XML namespace.
AMP recognizes a processor child element of the extension-point element. This allows the
extension point to define the processing visitor declaratively rather than in code. If the
processor is declared in the extension point definition, the parameter to the processExts()
method is optional. When no parameter is passed, a processor is created via the getProcessor()
method of the jsx3.amp.ExtProc class. See the General Interface API Guide for more
information.
Processor Types
This section describes the built-in processor types that cover the most common extension point
contracts.
Type eval
The inner text content of every extension child element is taken as a script and evaluated in the
context of the extension object. The extension elements may define the attribute load="true". In
this case, the plug-in that defines the extension is loaded before the script is evaluated.
Therefore, the script can be evaluated synchronously (load="false") or asynchronously (
load="true"). Example (Descriptor file):
<extension-point id="xp">
<processor type="eval"/>
</extension-point>
<extension point="com.tibco.example.p1.xp">
<eval load="true">this.getPlugIn().doSomething();</eval>
</extension>
this.getExtPoint("xp").processExts();
Type return
The inner text content of every extension child element is taken as a script and evaluated in the
context of the extension object. The value of the evaluated script is returned by the extension
processor. Example (Descriptor file):
<extension-point id="xp">
<processor type="return"/>
</extension-point>
<extension point="com.tibco.example.p1.xp">
<eval>this.getPlugIn()</eval>
</extension>
this.getExtPoint("xp").processExts().each(function(rv) {
jsx3.log("Script returned: " + rv);
});
In this case, the extension point contract does not specify whether or not the extending plug-in
is loaded before the script is evaluated. Either the extending plug-in must be able to evaluate
the code without being loaded or the processing plug-in must load the extending plug-in before
evaluating the script.
Type return-async
This type is the same as the return type, except that the extension elements may declare
load="true". In this case, the plug-in that declares the extension is loaded before the script is
evaluated. The processor object returns an object of type jsx3.$AsyncRV instead of the actual
value of the script, because the script may be evaluated asynchronously. Example (Descriptor
file):
<extension-point id="xp">
<processor type="return-async"/>
</extension-point>
<extension point="com.tibco.example.p1.xp">
<eval load="true">this.getPlugIn()</eval>
</extension>
this.getExtPoint("xp").processExts().each(function(rv) {
rv.when(function(v) {
jsx3.log("Script asynchronously returned: " + v);
});
});
Type instantiator
The instantiator type instantiates an object of a custom class for every child element of every
extension declaration. The instance-class attribute should be the fully qualified name of a
General Interface class. The class must define a constructor with the following signature:
<extension-point id="xp">
<processor type="instantiator"
instance-type="com.tibco.example.XDescriptor"/>
</extension-point>
<extension point="com.tibco.example.p1.xp">
<descriptor id="foo1" .../>
<descriptor id="foo2" .../>
</extension>
this.getExtPoint("xp").processExts().each(function(o) {
jsx3.log("Instantiated: " + o);
});
jsx3.amp.ExtProc.addProcessorFactory("customType",
function(procXML) {
return {process: function(ext, xml) {
return procXML.attr("prefix") + "-" + xml.attr("id");
}};
}
);
Registering this custom processor type allows the following processor definition in the plug-in
descriptor file:
<extension-point id="xp">
<processor type="customType" prefix="p"/>
</extension-point>
When a processor is defined declaratively for an extension point in the plug-in descriptor file,
the argument to the processExts method is optional:
this.getExtPoint("xp").processExts().each(function(e) {
jsx3.log("Extension: " + e);
});
The processExts method returns the list of values returned by the process method of the
processor, which was returned by the processor factory. The following extension definition
<extension point="com.tibco.example.p1.xp">
<item id="001"/>
<item id="002"/>
</extension>
would log the following when the extension processing code included above executes
Extension: p-001
Extension: p-002
The class attribute is the fully-qualified name of the class constructor function. The class must
be defined before the plug-in is registered, because the plug-in cannot be instantiated if the
class is not loaded. Therefore, define the class inline in the plugin.xml descriptor file (in a script
element) or in an early load resource of a required plug-in. This also holds for custom extension
point and extension classes.
You can use custom extension point and extension classes by declaring the class attribute of
their declarations.
Extending one of these classes allows you to define custom logic on instances of plug-ins,
extension points, and extensions. You can use either of the following techniques; the
appropriate technique depends on how you like to organize code and whether you want to
define the same methods on a single instance or on multiple instances. Use the first technique
when you want to define members on a single instance.
Use the script, method, and field elements, and JavaScript resource with eval ="true" to
define fields and methods on these objects.
Extend a class if you want to define the same methods on multiple instances of a plug-in,
extension point, or extension.
An AMP application must enable the AMP add-in. Use the Project Settings dialog in
General Interface Builder.
A non-AMP General Interface application defines a default component file that the runtime
loads when the application loads. This setting is managed in the Project Settings dialog or with
the objectseturl deployment parameter saved in the config.xml file. AMP applications do not
define a default component file. Rather, they extend the jsx3.amp.main.layout extension point
to provide a layout. The declaration of this extension point documents its contract.
<!-- Exactly one plug-in should extend this point to provide the
<extension point="jsx3.amp.main.layout">
<eval>[function (parent) {
var b = new jsx3.gui.Block();
b.setText("Hello World");
parent.setChild(b);
}][0]
</eval>
</extension>
The array literal syntax ([function(){}][0]) is included to make sure that the script evaluates
to the function reference rather than just declaring a function in the global scope.
A non-AMP application defines an onLoad script that is executed as soon as the application
paints for the first time. Instead of defining such a script in the Project Settings dialog, an AMP
application extends the jsx3.amp.main.init extension point. The processor on this extension
point is the simple eval type.
<extension point="jsx3.amp.main.init">
<eval load="true">this.getPlugIn().onAppInit();</eval>
</extension>
See the General Interface AMP API documentation for more information.
Plug-In: jsx3.amp.util.menumgr
This plug-in allows a menu bar to be composed of AMP extensions. This plug-in is helpful if an
application requires an extensible menu bars or context menus.
Plug-In: jsx3.amp.util.prefspanel
This plug-in implements an extensible preferences panel. Panes may be added to the panel via
AMP extensions.
Plug-In: jsx3.amp.util.wizard
This plug-in implements a wizard control. Wizard panes may be added to the wizard via AMP
extensions.
Plug-In: jsx3.amp.util.toolbarmgr
This plug-in allows a toolbar to be composed of AMP extensions.
jsx3.app.UserSettings
jsx3.gui.Alerts
jsx3.gui.Block
jsx3.gui.BlockX
jsx3.gui.Button
jsx3.gui.CheckBox
jsx3.gui.ColorPicker
jsx3.gui.DatePicker
jsx3.gui.Dialog
jsx3.gui.Form
jsx3.gui.Image
jsx3.gui.ImageButton
jsx3.gui.LayoutGrid
jsx3.gui.Matrix
jsx3.gui.Matrix.Column
jsx3.gui.Menu
jsx3.gui.Painted
jsx3.gui.RadioButton
jsx3.gui.Select
jsx3.gui.Slider
jsx3.gui.Sound
jsx3.gui.Splitter
jsx3.gui.Stack
jsx3.gui.StackGroup
jsx3.gui.Tab
jsx3.gui.TabbedPane
jsx3.gui.Table
jsx3.gui.TextBox
jsx3.gui.TimePicker
jsx3.gui.ToolbarButton
jsx3.gui.Tree
jsx3.gui.Window
jsx3.gui.WindowBar
jsx3.net.Form
jsx3.net.Service
jsx3.xml.Cacheable
Plug-Ins
Each AMP application comprises a set of AMP plug-ins, the functional units of an AMP
application. As a developer, you decide how to decompose the application into its constituent
plug-ins. Consider plug-ins to be application components that are either present (loaded) or
absent (unloaded). In other words, design cohesive plug-ins that contain the parts of the
application that function together, and tie plug-ins loosely to each other.
When decomposing an application, keep in mind that an AMP application loads at the
granularity of plug-ins; by default, all parts of a plug-in are loaded together.
Plug-ins are defined with a plugin.xml descriptor file. Each plug-in has a unique identifier that
is also the name of the directory in which the plugin.xml file is placed.
<plugin xmlns="http://www.tibco.com/gi/amp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.tibco.com/gi/amp
http://gi.tibco.com/xsd/plugin.xsd"
id="com.tibco.example.plugin"
name="Example Plug-In"
version="0.1">
...
</plugin>
To register plug-ins, refer to them in the plugins.xml file, and place the file in the plugins
directory at the root of the General Interface application that uses AMP. Alternatively, you can
use the AMP API to register plug-ins programmatically. For each plug-in registered in the
plugins.xml file, there should be a directory in the plugins directory with a name equal to the
ID of the registered plug-in. Each of these directories should contain a plugin.xml file.
<plugins xmlns="http://www.tibco.com/gi/amp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.tibco.com/gi/amp">
<plugin id="com.tibco.example.p1"/>
...
</plugins>
You can locate the directory of a plug-in outside of the application's plugins
directory. In this case, the path attribute of the plugin element should be the relative
path from the plugins directory to the directory that contains the plugin directory.
<plugins>
<plugin id="com.tibco.example2.plugin"
path="../../otherApp/plugins/"/>
...
</plugins>
An extension point is often designed to accept any number of extensions (one-to-many) but can
also be designed to accept only one extension (one-to-one) or a specified number of extensions.
The cardinality is not specified declaratively; it is enforced by the JavaScript code that processes
the extensions.
<plugin id="com.tibco.example.p1"/>
<extension-point id="example-xp"/>
</plugin>
An extension is a concrete implementation of the extension point contract. You can define an
extension in the same plug-in that defines its extension point or in another plug-in. In both
cases, the point attribute of the extension element is the fully-qualified identifier of the
extension point. The fully-qualified identifier is the id attribute of the extension-point element
appended to the identifier of its plug-in and separated with a period (".").
<plugin ...>
<extension point="com.tibco.example.p1.example-xp">
...
</extension>
</plugin>
The extension point-extension relationship is loosely coupled and controlled by the extension
point. It is possible for an extension to extend an extension point that is not registered.
Similarly, it is usually acceptable for an extension point to have no extensions.
<plugin ...>
<resources>
<script id="js" path="logic.js"/>
<xml id="xml" path="data.xml" load="manual"/>
...
</resources>
</plugin>
Resources can declare a load setting with the load attribute, as in the example above. The
possible values are early, normal (the default value), and manual. The load setting affects when
the resource is loaded in relationship to the plug-in life cycle.
You can also define resources inline in the plugin.xml file. Instead of defining the path
attribute, you can nest the file contents in a <data> element inside the resource element. For
JavaScript and CSS resources, the nested <data> element is optional; for example, you can
define a script in the text content of the <script> element.
The inline resource definition must be valid XML. Characters that are valid
JavaScript or CSS but invalid XML must be properly encoded. Consider using a
CDATA block for better readability.
<resources>
<script id="js"><![CDATA[
this.getLog().info("Loaded resource js.");
]]></script>
</resources>
XML, XSL and dynamic properties resources are defined inline as a document fragment. When
defining these resources inline, make sure that you define the correct XML namespace for the
content. If the xmlns attribute is not specified, the document fragment will inherit the AMP
XML namespace.
Copyright © TIBCO Software Inc. All Rights Reserved.
247
XML namespace.
<resources>
<xml id="info">
<data>
<info xmlns="">
<item id="1"/>
</info>
</data>
</xml>
</resources>
A plug-in can depend on another plug-in by declaring that it requires it in its descriptor file.
When a plug-in requires another plug-in, then the required plug-in will load ( step 5, above)
before the requiring plug-in. In addition, the required plug-in is instantiated before the
requiring plug-in. This means that all early load resources of the required plug-in are loaded
before the early load resources of the requiring plug-in.
<plugin id="com.tibco.example.p1">
<requires>
<plugin id="com.tibco.example.lib"/>
</requires>
...
</plugin>
Similarly, a resource may require that another resource be loaded before it is loaded. A resource
can also declare that a plug-in loads before the resource. This second option is useful for
manual load resources for which the plug-in does not declare the dependency. In the following
example, the com.tibco.example.lib plug-in loads before logic.js and logic.js loads before
SampleClass.js.
<plugin id="com.tibco.example.p1">
<resources>
<script id="js" path="logic.js">
<prereq plugin="com.tibco.example.lib"/>
</script>
<script id="SampleClass" path="SampleClass.js">
<prereq id="js"/>
</script>
</resources>
...
</plugin>
<plugin>
<event id="saved">
<param id="value" type="String"/>
</event>
</plugin>
The nested param elements are for documentation purposes only and are not
validated at runtime.
CustomPlugIn.prototype.save = function(strValue) {
// Perform the save
this.publish({subject:"saved", value:strValue});
};
Event registration can be performed declaratively as in the following example. The inner text of
the subscribe element is taken as a script to be evaluated in the context of the plug-in that
declares it. The variable evt is defined in this context and is equal to the event object that was
published.
<plugin>
<subscribe event="com.tibco.example.p1.saved">
this.getLog().info("The saved event was published with
value: " + evt.value);
</subscribe>
</plugin>
Instead of declaring the event subscription as a block of JavaScript code in the content of the
subscribe element, you can use the handler attribute to reference a method on the plug-in object
that will handle the event.
<plugin>
<method id="evtHandler" params="evt">
this.getLog().info("The saved event was published with
value: " + evt.value);
</method>
<subscribe event="com.tibco.example.plugin.saved"
handler="evtHandler"/>
</plugin>
Asynchronous Execution
AMP is built from the ground up around asynchronous execution. All plug-ins and their
resources are loaded asynchronously, and no synchronous APIs are provided.
Asynchronous loading performs much better than synchronous loading, especially over a
high-latency HTTP connection. Asynchronous loads do not block the browser's UI thread,
whereas synchronous loads do block the UI thread. However, asynchronous JavaScript code is
usually harder to develop than synchronous code. The result has often been an unfortunate
trade-off between developer productivity and application performance.
AMP also takes advantage of the powerful asynchronous idioms in General Interface. The
centerpiece of these idioms is the jsx3.Y() function, which declares an asynchronous method.
Asynchronous methods defined using Y have a strict contract that helps promote uniformity
across all asynchronous code. An example of these idioms is in the load() method of
jsx3.amp.Resource. The following example shows how an action is performed when both rsrc1
and rsrc2 have loaded asynchronously.
this.getResource("rsrc1").load().and(
this.getResource("rsrc2").load()).when(function() {
// Perform an action
});
See the General Interface API documentation for a detailed description of the jsx3.Y() method
and its related objects.
Packaging Resources
Decomposition into components is a powerful tool for decreasing coupling between logical
components and managing application complexity. AMP makes it easy to package resources
into a cohesive plug-in. These resources can refer to other resources within the same plug-in
without much boiler plate code and without reference to a global namespace.
Plug-ins, extension points, and extensions can define fields and methods and execute arbitrary
code inside the plugin.xml descriptor file. The elements script, method, and field can be
children of the plugin, extension-point, or extension elements. In the following example, the
script element this refers to the parent object.
<script>
this.getLog().info("I am plug-in: " + this);
</script>
<field id="strValue">"value"</field>
By convention, this is defined to be the parent object (plug-in, extension point, or extension)
containing an XML text block that is interpreted as a script field. This convention is evident in
the script element above, the declarative event subscription mechanism and the standard
extension point processors, eval, return, and return-async. We recommend that you follow the
AMP convention when you define how your own extension points interpret their extensions.
Another useful feature is the eval attribute of a script resource. When this attribute is set to true
, it causes the contents of the JavaScript file to be evaluated in the context of the plug-in
instance. The following example shows how this is used in an external JavaScript file.
(function(plugIn) {
plugIn.doSomething = function() {
// do something here
};
})(this);
1. A getPlugIn() method is defined on the root object of the component file that returns the
plug-in on which loadRsrcComponent() was called.
2. The component file is loaded with the plug-in as the URI resolver. This means that all
relative paths are resolved relative to the directory of the plug-in.
The first item above makes it easy for all the code, whether defined in a JavaScript file or in the
onAfterDeserialize block of a component file, to refer to the plug-in that contains the code. The
second means that all paths contained in plug-in resources are defined relative to the plug-in
itself. The following example shows a component file that takes advantage of these features.
<serialization xmlns="urn:tibco.com/v3.0">
<onAfterDeserialize><![CDATA[
objJSX._onBtnClick = function() {
this.getPlugIn().performAction();
};
]]></onAfterDeserialize>
<object type="jsx3.gui.Button">
<strings jsxtext="Click Me"/>
<events jsxexecute="this._onBtnClick()"/>
</object>
</serialization>
Build Tools
The source distribution of General Interface 3.8 includes build tools that specifically aid in the
deployment of high performing AMP applications.
One obvious downside of AMP applications is that application decomposition results in a large
number of resource files. Loading a large number of files is usually much slower than loading
fewer files, even when the sum size of the files is the same. This is especially true over an HTTP
connection.
AmpResourceMergeTask. This tool merges the resources of a plug-in into the plugin.xml
descriptor file. This process takes advantage of the fact that most types of resources can
be included inline in the descriptor file directly beneath the resource element.
AmpPluginMergeTask. This tool merges plug-ins into the plugins.xml file. Just as resources
can be included inline in plugin.xml, plug-ins may be included inline in the plugins.xml
file.
By using these tools, you can deliver an AMP application with as few as two files, by contrast
with the large number of files that would otherwise be required.
There are potential disadvantages in loading all resources in one file, because many resources
may be used only in rare application use cases. For this reason, the build tools include options
to merge a subset of the application plug-ins and resources.
<target name="mergeAmpPlugIns">
<!-- Define the AMP Ant tasks.
jsx-tools.jar created from source distribution -->
<taskdef resource="com/tibco/gi/ant/antlib.xml">
<classpath path="jsx-tools.jar"/>
</taskdef>
AMP Localization
This section describes how to localize an AMP application using localization features in AMP
and in the General Interface Framework.
Resources
A plug-in can localize one of its resources by registering multiple versions of the resource, one
for each locale. The locales attribute registers these versions and is supported for all resource
types. It is a whitespace-separated list of locale keys, as in the following example.
<resources>
<xml id="data" path="data.xml" locales="en fr de"/>
</resources>
This resource declaration implies that the following files exist in the plug-in's directory.
data.xml
data.en.xml
data.fr.xml
data.de.xml
Plug-in Metadata
You can localize the plug-in descriptor file using a technique similar to that used for resources.
With this technique, you can localize the metadata that is part of the extension point and
extension declarations.
Localized versions of plugin.xml are registered with the locales attribute of the plugin element
in the main plugin.xml file. This attribute is a whitespace-separated list of locale keys for which
implies that the following files are in the plug-ins directory in addition to plugin.xml, the
contents of which are shown above:
plugin.es.xml
plugin.de.xml
By contrast with localized resources, where the entire resource is replaced with the localized
version of the resource, the contents of the localized version of the plug-in descriptor file are
merged into the main descriptor file. This is handy because usually most of the plugin.xml
content does not need to be localized (such as JavaScript functions).
The following algorithm is used when merging the localized plug-in descriptor file into the
main descriptor file:
1. Copy all attributes of the localized document element plug-in into the base file.
2. For each extension-point element in the localized document, search for an
extension-point element in the base file with the same value for the id attribute. If that
element exists, do the following:
a. Copy all attributes from the localized element into the base element.
b. If the localized element has one or more child elements, replace all the children of
the base element with the children of the localized element. Elements script,
method, field, and processor are not removed from the base element.
3. For each extension element in the localized document, search for an extension element
in the base file with the same value for the id attribute. If that element exists, do the
following:
a. Copy all attributes from the localized element into the base element.
b. If the localized element has one or more child elements, replace all the children of
the base element with the children of the localized element. Elements script,
method, and field are not removed from the base element.
There is no locale "fall through" for localized plug-in descriptor files. For example, if
plugin.xml is localized for locales en and en_US, and the application locale is en_US,
the merged file is the combination of just plugin.en_US.xml and plugin.xml. In this
case, plugin.en.xml is not used in the merge. However, if plugin.xml is localized
only for the locale en and the application locale is en_US, then the merged file is the
combination of plugin.en.xml and plugin.xml.
Property Bundles
For fine grained localization using string replacement and message formats, AMP offers a
properties bundle resource type.
<resources>
<propsbundle id="messages" path="messages.xml"/>
</resources>
The format of messages.xml is specified by the jsx3.app.PropsBundle class from the General
Interface core library.
Copyright © TIBCO Software Inc. All Rights Reserved.
254
After this resource is loaded, the localized strings that it contains are available in the following
ways:
<data jsxid="jsxroot">
<record jsxid="id" jsxtext="{key}"/>
</data>
One possible application of this functionality is in a extension point contract, as in the following
extension point declaration:
<extension-point id="keys">
<!-- Expects any number of key elements. The id attribute is taken as a key from
the messages resource of this plug-in -->
</extension-point>
<extension point="com.tibco.example.key">
<key id="key"/>
</extension>
It is then up to the extension processing logic to interpret the id attribute as a property key:
For more information, see the "Internationalizing and Localizing Applications" chapter in the
General Interface Developer Guide.
General Interface (GI) includes an optional add-in module called the Asynchronous Modular
Platform (AMP) to address some of the inherent difficulties encountered during the
development of a large application. AMP provides a modular framework for GI developers to
create application units called plug-ins which contain design components and other resources.
The intent of this guide is to examine the AMPsample application and each of its plug-in
examples and look at how they individually contribute to the overall application.
MenuManager
ToolbarManager
Event publishing/subscribing
jsx3.amp.persist plug-in
The running application has a series of menus and buttons that change the color of the
background screen. In addition, there are two dialog examples to demonstrate a multi-screen
"wizard" technique of gathering information and another to set a property.
There are a set of menus and buttons on the main layout screen that are populated during the
initialization of each plug-in module. The selection of either the menu item or the button will
change the application background to a different color.
Additionally, there is a plug-in with an associated menu called "Locale" that creates the text of
each menu item by iterating through a list of language locales to convert them to their longer
name. For example, the code "en" is transformed to "English".
In total, there are eight plug-in modules in seven directories that constitute the overall
functionality of the application and each plug-in handles its own set of capabilities. The next
section will begin investigating the structure of the AMPsample application.
Structure
A GI AMP project contains a directory named "plugins" and within it a descriptor file called
"plugins.xml" is used to register each plug-in. An AMP engine is instantiated for every AMP
application at runtime.
Each plug-in can be contained in its own directory structure. The name and path of the
directory is part of the reference given in the plugins.xml file. The AMP engine processes
plug-ins in the order that they are listed in the plugins.xml registry file.
As part of the registry entry, a path can be provided to reference the containing directory. For
instance, you can use a relative path to another project with the following:
As the AMP engine processes each of the plug-in entries, it will assume the default path is
relative to the "plugins" directory and will look for a directory with the same name as the
plug-in "id" attribute. The plug-in directory will contain a file that describes the plug-in
components and uses a default name of "plugin.xml". Note: it is also valid to bypass the
referenced file and enter the same information entirely within the plugin element. However,
keeping the plugin.xml file with the rest of its resources seems like a better practice.
The format of the plugins.xml file adheres to the plugins.xsd schema located at
http://gi.tibco.com/xsd/plugins.xsd and http://www.generalinterface.org/xsd/plugins.xsd.
<plugins xmlns="http://www.tibco.com/gi/amp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.tibco.com/gi/amp http://gi.tibco.com/xsd/plugins.xsd">
<plugin id="init">
<method id="onRegister">
if (localeId)
this.getEngine().getServer().setLocale(jsx3.util.Locale.valueOf(localeId));
</method>
</plugin>
<plugin id="main"/>
<plugin id="red"/>
<plugin id="yellow"/>
<plugin id="purple"/>
<plugin id="settings"/>
<plugin id="locale"/>
<plugin id="progress"/>
</plugins>
The first plug-in is identified by "init" and has a method available named "onRegister". The
method's JavaScript will execute automatically after the plug-in is registered by the engine.
Each plug-in is loaded in the order that it appears in the list; therefore the second plug-in is
"main". Let's take a look at the plugin.xml file associated with main.
<plugin xmlns="http://www.tibco.com/gi/amp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.tibco.com/gi/amp http://gi.tibco.com/xsd/plugin.xsd"
id="main"
name="UI Plug-In"
version="0.1">
The plugin.xml descriptor file starts out with the "plugin" element name and the schema names
associated to namespaces. The attribute "id" matches the registered plug-in entry in the
plugins.xml file and must be unique. The version attribute is arbitrary and could be used to
Copyright © TIBCO Software Inc. All Rights Reserved.
258
plugins.xml file and must be unique. The version attribute is arbitrary and could be used to
check if the version of the plug-in supports certain capabilities for example. The id, name and
version attributes can be read programmatically using the jsx3.amp.PlugIn class API.
The next section of the plugin.xml file describes which GI classes will be required in order for
the plug-in to run properly.
<requires>
<plugin id="jsx3.gui.Block"/>
<plugin id="jsx3.amp.util.menumgr"/>
<plugin id="jsx3.amp.util.toolbarmgr"/>
</requires>
In this case, the "main" plug-in will depend on the three declared classes. The engine manages
the loading of the classes. All required plug-ins will be registered and instantiated before the
plug-in is registered.
The next section of the plugin.xml file defines the resources used by the plug-in. Six resource
types are allowed inside the resource tags:
<resources>
</resources>
An optional attribute can be added to a resource element to designate how the engine should
load it. Three options are available: early, normal and manual. If the resource type is "script"
and the "eval" attribute is "true", the engine will read the JavaScript and load it into memory.
The life-cycle.
<event id="colorChanged">
</event>
Event processing.
Copyright © TIBCO Software Inc. All Rights Reserved.
259
Event processing.
<extension-point id="menu">
</extension-point>
<extension-point id="menu-item">
</extension-point>
<extension-point id="toolbar">
</extension-point>
<extension-point id="content">
</extension-point>
Extension points
</extension>
</menu>
<!--
</menu>
-->
</menu>
</menu>
</extension>
Extensions
</plugin>
About $Y
Calling Asynchronous Functions
Designing Asynchronous Functions
Using $Z
Asynchronous AMP APIs
About $Y
$Y allows you to write concise and readable asynchronous code, providing the following
capabilities:
A standard way to pass and handle callbacks and a standard way to send return values
Multiple callbacks per asynchronous call
Condition chaining
Asynchronous method chaining via automatic parameter resolution
Return value chaining
You can use $Y instead of the following "anti-patterns" for asynchronous JavaScript
programming:
The following code examples all show an asynchronous method that loads an XML
document and sample code that uses the method.
loadXmlAsync("data.xml", function(doc) {
jsx3.log("Got document: " + doc);
});
As shown in the example, passing a callback function works but can get messy and there is no
Copyright © TIBCO Software Inc. All Rights Reserved.
262
As shown in the example, passing a callback function works but can get messy and there is no
standard idiom. The following questions may arise:
this.loadXmlAsync = function(url) {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
this.publish({subject:"done",
doc: req.responseXML});
};
req.open("GET", url, true):
req.send();
};
this.subscribe("done", function(evt) {
jsx3.log("Got document: " + evt.doc);
});
this.loadXmlAsync("data.xml");
The following example shows how to use $Y to implement the function in the previous
examples.
this.loadXmlAsync = jsx3.$Y(function(cb) {
var url = cb.args()[0];
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
cb.done(req.responseXML);
};
req.open("GET", url, true):
req.send();
});
this.loadXmlAsync("data.xml").when(function(doc) {
jsx3.log("Got document: " + doc);
});
A Simple Example
Any function passed to the when() method of jsx3.$AsyncRV is called when the asynchronous
method is done.
The function is passed a single parameter, which is the asynchronous return value of the
asynchronous function, as in the following example:
var rv = loadXmlAsync("data.xml");
rv.when(function(doc) {
jsx3.log("The asynchronous return value is: " + doc);
});
Multiple Callbacks
A program can call when() any number of times before or after the asynchronous method
finishes. Regardless of when it is called, all callbacks are invoked. For example:
var rv = loadXmlAsync("data.xml");
rv.when(function(doc) {
jsx3.log("Got document: " + doc);
});
rv.when(function(doc) {
doSomethingElse(doc);
});
Condition Chaining
Use the and() and or() methods of jsx3.$AsyncRV to chain asynchronous return conditions.
Both methods also return instances of jsx3.$AsyncRV. For example:
This can eliminate a call to when() and an anonymous function, thereby improving code
readability and conciseness.
The previous code is equivalent to but more concise than the following code.
In most cases, the synchronous return value (the argument of the return statement) of the
function is ignored.
window.setTimeout/jsx3.sleep
Other Y functions
Method Parameters
You can call the wrapping function with any parameters.
Because the wrapped function takes exactly one parameter, cb, the parameters passed to the
wrapping function are accessible via cb.args(). For example:
Return Value
You can define an asynchronous return value by passing it to cb.done().
The return value is passed to any callback registered with when(). It is also retrievable via the
rv() method of jsx3.$AsyncRV. For example:
asyncFct("data1.xml").when(function(doc) {
jsx3.log("Got document " + doc);
});
asyncFct("data1.xml").when(function(doc) {
jsx3.log("Got document " + doc);
});
You cannot use variables of type jsx3.$AsyncRV with control statements, such as if.
However, parameter resolution allows you to use parameters with control
statements. As a workaround, you can pass such variables to another function.
Using $Z
$Z is another useful utility method that is similar to $Y. Like $Y, it returns a wrapping function
that conforms to the contract of an asynchronous function. (The wrapping function always
returns an instance of jsx3.$AsyncRV.) Unlike $Y, $Z enforces no contract on the wrapped
function. jsx3.$Z allows you to use automatic parameter resolution and return value chaining
with normal, synchronous functions, as in the following example:
In Engine: register()
In PlugIn: load(), loaded()
By simplifying test case development, the Test Recorder dramatically reduces the barriers to
creating comprehensive test suites for your General Interface applications.
There are two types of events that may change the state of the application:
An event with a registered event handler. Because the event handler typically calls
application logic, it can cause the state of the application to change. Event handlers are
set in the Events Editor palette in General Interface Builder.
Specific events known by the system to change the state of the application. These include
jsxshow on Tab, jsxselect on Select, and others that cause the display or value of a GUI
control to change. These are recorded because they change the state of the application,
even if nothing is listening for them. By contrast, an execute event, such as a mouseover,
does not change the state of the application and is not recorded, unless custom logic is
added.
For information on how to design custom GUI controls that are compatible with the Test
Recorder see Designing Recordable Controls.
By restricting the recorded events to those that are important to the functional behavior of the
application, the Test Reorder helps you construct useful test cases with a minimum of
Copyright © TIBCO Software Inc. All Rights Reserved.
269
application, the Test Reorder helps you construct useful test cases with a minimum of
extraneous noise.
If you are using Internet Explorer, make sure that Allow Active Content to Run in
Files on My Computer is selected before launching the Test Recorder. The setting is
in the Advanced section of Tools > Internet Options.
3. Click the Launch Recorder button to open the Test Recorder recording interface.
Before launching the Test Recorder, make sure that your browser opens
pages in a new window instead of a new browser tab. This allows you to
see what is occurring in General Interface Builder while you interact with
the Test Recorder.
The next figure shows an example. The recorder buttons are at the top, and the main body of
the window shows a sample address validation application.
Item Description
Icons that toggle between Pause and Resume. Pause stops recording
Pause icon
application interactions until the Resume button is clicked.
Resume icon
Recording an Application
As you interact with your application, the Test Recorder records the interactions and displays
them in the test case table from which you started the Test Recorder.
The process works as follows for the sample zip code application. This sample is available in
the samples that ship with General Interface. To open the sample project, choose Project > User
Projects > samples > WSDL_Mapping_1.
1. Enter a zip code, and a change event is recorded with the target object #zip. The change
event is added as a row in the test case table tab from which you launched the Test
Recorder. The event action is jsxchange, and the target is #zip. The Test Recorder also
records event metadata, shown in the Value column, which allows the Test Recorder to
play back the event.
2. Click Find City and State, and a new event is added to the test case table. The event
action is jsxexecute, and the target is #lookupButton.
3. Another event is added when you dismiss the pop-up success message.
4. To verify that the application is working, click the Wait button. This puts the recorder in
"wait" mode. The next click on the application will generate a wait test case instead of
recording a model event. The recorder automatically picks what it determines to be the
most appropriate command. You can change the command later, if needed, in the test
case table. As shown in the next figure, clicking on a text box generates a jsxwait_value
event.
In the sample zip code application, the target it #city and the value is "San Francisco."
This means that when the action is replayed by GIPP or GITAK, it will wait until the
value of #city equals "San Francisco."
When constructing test cases, it is best to interact with the application and then do a
single wait or assert operation. For a list of wait actions, see Working with the Test Case
Table.
When the recording is complete, you can go to the test case table and make
modifications. In general, the recorder makes a best guess as to your intentions;
however, because many interactions have multiple interpretations, you may need to
manually edit some entries.
For example, the next figure shows the result when the Wait button was clicked twice
during recording. By returning to the test case table, you can delete the second instance
of the wait event.
5. To keep the generated test cases, save the test case table. GIPP test cases require a .js
extension and GITAK test cases require an .html extension.
6. After saving the recorded file, you can run the test case by launching it in GIPP or
GITAK. Before doing so, make sure that GIPP and GITAK are configured. To do so,
choose Tools > IDE Settings. Click GIPP & GITAK and specify the appropriate
installation directory.
Copyright © TIBCO Software Inc. All Rights Reserved.
6.
274
installation directory.
7. Click the Launch GIPP or Launch GITAK button in the builder window.
Clicking the Launch in GIPP button launches only the current file. To run
GIPP with all of the available test cases, choose Project > Run Project in
GIPP.
ID/Label---GIPP only, optional. The ID distinguishes between test cases; there can be
only one ID assigned within a test case. (If you do not assign an ID, the Test Recorder
automatically assigns the value 1.) This column is not included in the GITAK version of
the test case table, because GITAK supports only one test case per test case table.
Action---Drop-down list of built-in actions. Note that when you record an assert or wait
action while interacting with your application, the Test Recorder tries to automatically
determine the best action to take. You can change any automatically chosen actions by
selecting another value from the drop-down list.
GIPP Actions
GITAK Actions
Target---Unique address for the GI object to which the action applies. The Test Recorder
automatically resolves name collisions to assign a unique address. The syntax of this
address is defined by the jsx.app.Model.selectDescendents() method. For more
information, refer to the API documents available at
http://www.generalinterface.org/docs/display/DOC/Learning+Center.
Value---Argument or value of the action. Allowed values are determined by the action
type. Examples may include a text value or 0 or 1 for a check box field. For model events,
the value consists of metadata that was part of the event and object. The metadata is the
schema of the model event object and includes the attributes that are necessary for the
replay action. To record properly, it is necessary to know not only that there is a change,
but what the change is. The schema in the value column can also include a previous
value that is saved for possible future use.
To add an event, click Insert a Row. Choose the action from the drop-down list and
Copyright © TIBCO Software Inc. All Rights Reserved.
276
To add an event, click Insert a Row. Choose the action from the drop-down list and
specify the target.
To edit an event, highlight the row and make changes as needed.
To reorder rows, select them and drag from the leftmost column.
To delete an event, highlight the event and click the Delete icon on the right.
For , deleting the extra jsxexecute event and jsxwait_value events in the zip code example
results in a simplified three-event test case, as shown in the next figure. The test case consists of
the following events:
Contains a wait action. There can be only one wait action per test case.
Defines a value for ID/Label.
As you set or clear a value in the ID/Label column or toggle an entry in the Action column
between a wait and other action, you can see the thick blank line that delineates the test case
appear in the appropriate place.
The JavaScript code that defines the recorded events is located between the lines
and
The last line in the file invokes GIPP on the data structure, and must not be moved or removed.
Below the link Insert manual tests here, you can optionally add documented GIPP methods.
For example, the next figure shows the addition of a new test case, manual1, after the test1 test
case.
The manual test case does not appear in the table in General Interface Builder, but it is included
when the cases are actually run. For example, the next figure shows how the manual test case
appears in GIPP.
When you click Launch in GITAK, GITAK opens with the test case displayed. The test
suite is generated automatically to run from Builder. The purpose of the Test Recorder is
to help you construct the test case. Note that the wait and assert actions are not listed.
Model Events
The custom control must use General Interface model events in the following ways:
A model event must be published after any user interaction that changes the state of the
control. This type of published event must define the event property _gipp and set it to
be equal to 1.
All events that the control publishes and which may have an arbitrary number of
subscriptions must be published as a model event.
The following example shows a method that is called when the user clicks on a hypothetical
control.
The first published model event, click, allows the event handler to veto the change in value
that occurs by default when the user clicks on the control. It does not necessarily indicate a
Copyright © TIBCO Software Inc. All Rights Reserved.
280
that occurs by default when the user clicks on the control. It does not necessarily indicate a
change in value of the control, so it does not define the _gipp property.
The second published model event, change, indicates that the control state did change, so it
defines the _gipp property. This ensures that the event is recorded by the Test Recorder even if
no event handlers are registered for the change event.
Playback
The custom control must include code that replays the recorded events and changes its own
state as if the event were caused by a real user interaction. This code is invoked by GIPP or
GITAK during test replay.
To replay the recorded event, implement a replayEvent() method in the control's class, as in
the following example.
ClickCounter.prototype.replayEvent = function(objEvent) {
if (objEvent.subject == "change") {
// handle the change event by changing the control value
this.value = objEvent.newVal;
this.doEvent(objEvent.subject, objEvent);
} else {
// handle click and other events that don't affect the control state
this.doEvent(objEvent.subject, objEvent);
}
}
In this example, the replay logic sets the value of the control to the value of the newVal event
property, which was set in the first code example when the change event was published.
Typically, this method also calls doEvent() in case there are any subscriptions on the event.
In this case, the newVal event property is necessary to replay the event properly. Without this
property, the change in application state that occurs when the event is recorded can not be
applied when the event is replayed. There must be similar cooperation between the code that
publishes an event (with _gipp:1) and the code in replayEvent() that replays the event.
For an overview of the General Interface Builder user interface, see General Interface Getting
Started and General Interface Builder Basics.
Menu Commands
Toolbar Commands
Dialog Field Descriptions
Tool Field Descriptions
Menu Commands
This section describes General Interface Builder menu commands.
Project Menu
The Project menu includes the following commands.
Command Description
New Project Displays a prompt to create a new project and opens the new project in the
same browser window. A default project directory structure is also created on
the file system.
Recent Displays a list of the last ten projects that were opened. Clicking a project name
Projects opens the project.
User Displays a list of all projects in the workspace/JSXAPPS folder. Clicking a project
Projects name opens the project.
Project Displays the Project Settings dialog for configuring project deployment,
Settings add-ins, class path, and legacy settings for the open project.
Deployment Displays the Deployment Utility which is used to generate code for deploying
Utility the application in a browser. Create an HTML or XHTML launch page for
standalone applications or generate HTML code to insert applications into an
existing web page.
Run Project Runs the current project configuration in a new browser window to simulate
the runtime environment. The project runs in the same mode as General
Interface Builder, such as HTML or XHTML.
Run Project Runs the project in a new browser window on an HTTP web server as specified
from HTTP on the Paths panel of the IDE Settings dialog. If the HTTP server isn't
configured, you are prompted to configure it.
File Menu
The File menu includes the following commands.
New Creates a new, empty tab in the work area for the selected file type.
GUI Creates an empty GUI component file. Save with the .xml extension
Component in the components directory of the project.
XML Creates an empty XML file for content data, such as default values,
Document for the application. Save with the .xml extension in the xml
directory of the project.
XSL Creates an empty XSL file for transforming XML files containing
Document application data. Save with the .xsl extension in the xsl directory of
the project.
JavaScript Creates an empty JavaScript file. Save with a .js extension in the js
File directory of the project.
CSS File Creates an empty CSS file for defining application styles. Save with
a .css extension in the css directory of the project.
Dynamic Creates an empty dynamic properties resource file. Save with the
Properties .xml extension in the jss directory of the project. See Dynamic
File Properties Files.
Mapping Creates an empty mapping rules file for connecting to web services.
Rule Save with the .xml extension in the rules directory of the project.
See Mapping GUI Components to Mapping Rules.
Open Displays the File dialog for opening an existing file for use in the
application.
Recent Displays a list of recently created files. Clicking a file name opens
Files that file in the project.
Close Closes the active tab. If the file contains unsaved changes, you are
prompted to save the file.
Close All Closes tabs for all open files. If a file contains unsaved changes, you
are prompted to save the file.
Revert Displays a Confirm Revert dialog where you can choose to revert
the active file to the last saved state. After reloading, any recycled
objects are cleared from the Recycle Bin and cannot be recovered.
Revert All Displays a Confirm Revert dialog where you can choose to revert
all open files to the last saved state. After reloading, any recycled
objects are cleared from the Recycle Bin and cannot be recovered.
Save to For an XML cache document, saves the active file to the
Cache in-memory, local data cache.
Save and Saves the active file to disk and reloads the file appropriate to the
Reload file type. For example, JavaScript files (.js) are reloaded into the
browser memory space to reflect the updated code. After
reloading, any recycled objects are cleared from the Recycle Bin
and cannot be recovered. This menu isn't available for open data
cache files.
Save a For an XML cache document, opens the Save File dialog where you
Copy to can enter a new file name and save the file to disk.
Disk
Tools Menu
The Tools menu includes the following tools.
Command Description
XML/XSL Displays the XML/XSL Merge Tool, which displays the results of applying
Merge Tool an XSLT document. You can open multiple instances of this tool. See
XML/XSL Merge Tool.
XML Mapping Displays the XML Mapping Utility, which is used to map WSDL, Schema,
Utility and XML documents to application objects. See Communicating with Data
Services.
Color Picker Displays the Color Picker Tool for choosing color values. See Color Picker
Tool.
JavaScript Displays the JavaScript Console for executing and debugging JavaScript
Console code. See The JavaScript Console.
Find and Displays a search dialog for searching and replacing text in open text files.
Replace
General Links to the download site for General Interface Automation Kit, which
Interface Test you can use to test your General Interface applications.
Automation Kit
IDE Settings Displays a dialog for setting preferences for the visual authoring
environment, such as IDE settings, IDE hot keys, and paths. See
Customizing the IDE.
Palettes Menu
The Palettes menu includes the following palettes. Each of these palettes has a context menu.
See Palette Context Menus.
Local Data Displays or hides the Local Data Cache palette. Ctrl+7
Cache
Recycle Bin Displays or hides the Recycle Bin palette. Objects that have been Ctrl+9
deleted using the Component Hierarchy palette can be recovered
from the Recycle Bin.
Help Menu
The Help menu includes the following commands.
Command Description
Online User Opens the General Interface documentation page in a new browser window.
Guides
API Provides access to General Interface API Reference. You can view the API
Documentation documentation in a dialog, a separate window, or the HTML version in a
browser window. Also provides access to these additional references:
Getting Started Provides a link to the Learning Center home page, which contains links to
documentation, API reference, utility, samples, and other information.
Open Source Provides a link to General Interface Open Source Project, which provides
Project access to General Interface source code, public bug tracking, release builds,
and developer forums.
About General Provides version information for General Interface and General Interface
Interface Builder, as well as important legal notices.
Context Menus
To access a context menu, right-click an area of the user interface or right-click an object in a
palette, such as a file name in the Project Files palette. Press the Escape or Left Arrow keys to
close the menu.
Command Description
Clone Creates an exact copy of the selected object(s) and any children.
The new object is added as the last child of the selected object's
parent object.
Repaint Repaints the Live Component view in the work area to reflect
changes.
Re-Fetch Refreshes the data in the cache and repaints the Live
Data and Component view in the work area. Available for objects that
Repaint implement jsx3.xml.Cacheable.
Referenced Imports a link to a component file, not the actual contents of the
component. For example, <include
src="workspace/_prototypes/greenbutton.xml"
async="false"/>. The name of a referenced component in the
Component Hierarchy palette is displayed using blue italic font.
Export As XML Exports the selected General Interface DOM branch as an XML
file, which can then be used in other projects.
Copy Copies the Getter code for the object(s) to the clipboard. For
Getter example, myAddressLookup.getJSXByName("block").
Code to
Clipboard
Command Description
Copy Path Copies the path of the selected component to the clipboard. For example, the
path for the Dialog component would be
GI_Builder/prototypes/Containers/Dialog.xml.
Command Description
Command Description
View Markup Opens the selected document in the work area as a read-only, formatted
file.
Remove from Removes and deletes the selected document from the in-memory cache.
Cache
Command Description
Edit Opens the selected file in the work area for editing.
Edit Profile Displays the File Profile dialog where you can modify the file ID, file type, file
URI, and whether the file auto loads or not. See File Profile Dialog.
Auto Load Sets the selected file(s) to auto load when the application runs.
Dereference Dereferences the selected file and removes it from the project. The file isn't
deleted from disk.
Load/Reload Loads or reloads selected files from disk into browser memory.
Copy Path Copies the file path to the clipboard. For example, js/logic.js.
Command Description
Command Description
Save and Saves the active file to disk and reloads the file appropriate to the file type. For
Reload example, JavaScript files (.js) are reloaded into the browser memory space to
reflect the updated code. After reloading, any recycled objects are cleared from
the Recycle Bin and cannot be recovered. This menu isn't available for open data
cache files.
Save a For a cache document, displays the Save File dialog where you can save the file
Copy to to disk.
Disk
Save As Displays the Save File dialog where you can save the file with a different name
and to a different location.
If a file is read-only, a Lock icon displays on the work area tab. To open a locked,
read-only file, double-click the Lock icon.
Command Description
Wrap Text Wraps the text in the work area so all of the text is visible without horizontal
scrolling.
Command Description
Command Description
Add New Launches the Add Local dialog where you enter a locale key, such as en_US or
Locale es_ES (Spanish). After the key is entered, a new locale column displays in the
table in the Properties Bundle editor. For more on language and country codes,
see Locale Keys.
Command Description
Copy Path to Copies the project path to the clipboard. For example, workspace
Clipboard /JSXAPPS/myAddressLookup.
Project Displays the Project Settings dialog where you can modify project settings,
Settings such as deployment, add-ins, class path, and legacy settings. See Project
Settings Dialog.
Attribute Adds a new attribute rule to the selected rule. Attributes associate
name-value pairs with elements.
CDATA Adds a new CDATA rule to the selected rule. Text in a CDATA
section is ignored by the XML parser. CDATA sections begin with
the string <!CDATA( and end with the string]>.
Clone Clones a selected node in the rules tree, including its descendant
content.
Sample Displays a sample input message for the selected request rule and a
Message sample output message for the selected response rule.
Execute Runs a test on the selected operation rule in the rules tree.
(Quick
Test)
Toolbar Commands
This section describes General Interface Builder toolbar commands.
Button Description
Displays the active file in Live Component view. This view is available for GUI
components and dynamic properties files.
Displays the active file in Source XML/Source Text view. This view is available for all
file types.
Displays the active file in Formatted Source XML view. This view is read-only and is
available for XML, XSL, dynamic properties, and GUI component files.
Displays the active file in Rendered HTML view. This view is read-only and is
available only for GUI components.
Displays the active file in Component Profile view. This view is available only for
GUI components.
Button Description
Controls docking options for the palette, which include the following:
Press the Enter key to navigate the Attributes Editor palette fields.
Button Description
Controls docking options for the palette, which include the following:
Creates an exact copy of the selected object and any children. The new object is
added as the last child of the parent of the selected object.
Repaints the Live Component view of the selected object in the work area to reflect
changes.
Refreshes the data in the cache and repaints the Live Component view in the work
area. Available for objects that implement jsx3.xml.Cacheable.
Moves the selected object and its children, if any, to the Recycle Bin. There is a
separate Recycle Bin for each GUI component file.
Shows or hides the focus rectangle in the work area. Most GUI objects can be
selected in the work area using Ctrl+click. This button is off by default, because it can
interfere with interactions and events of the selected object's children.
Synchronizes the Component Hierarchy palette with the current version of the
hierarchy on disk.
Button Description
Controls docking options for the palette, which include the following:
Synchronizes the Component Libraries palette with the current version of the
libraries on disk.
Button Description
Controls docking options for the palette, which include the following:
Opens the selected file in a tab in the work area, where it can be edited.
Button Description
Controls docking options for the palette, which include the following:
Creates a new tab in the work area for the selected file type.
Displays the Open File dialog for adding an existing file to the project. Also opens
the file in a tab in the work area.
Opens the selected file in the project in a tab in the work area.
Opens the File Profile dialog, where you can edit file ID, type, Auto Load, and URI
values for the selected file. See File Profile Dialog.
Removes the selected file from the project. The file isn't deleted from disk.
Button Description
Empties all objects in the Recycle Bin and deletes them from memory. Deleted items
can't be recovered.
Button Description
Controls docking options for the palette, which include the following:
Controls the message log level. Choose from OFF, FATAL, ERROR, WARN, INFO, DEBUG, or
TRACE.
Button Description
Controls docking options for the palette, which include the following:
Press the Enter key to navigate the XSL Parameters palette fields.
Button Description
Saves the currently open rules file with a new file name.
Test Launches the Test Interface Tool where you can step
through and execute operations in the rules tree.
CDF Creates a CDF attribute mapping using the rule name as the
Attribute attribute name.
CDF Creates a CDF record for the selected rule(s) and CDF
Record attribute mappings for descendant rules.
Unselected Deletes all siblings of the selected rule(s) from the tree.
Sibling
Rules
Button Description
Controls the message log level. Choose from OFF, FATAL, ERROR, WARN, INFO, DEBUG, or
TRACE.
Button Description
Taskbar Toolbar
The taskbar is located at the bottom left of the General Interface Builder user interface.
Button Description
To open the Create a New Project dialog, choose Project > New Project or click the Create A
New Project link in the Welcome screen (Help > Welcome Screen).
Field Description
Project The name of the project and project directory, which is created in the JSXAPPS
Name directory. You can type the name or click the Browse button to browse to and enter a
folder name in the JSXAPPS directory.
Button Description
Create Creates the project and launches General Interface Builder with the project open.
To open the File Profile dialog, right-click a file in the Project Files palette and choose Edit
Profile. You can also select a file and click the Edit Profile button on the Project Files palette
toolbar.
Type Type of file, such as GUI Component, JavaScript, CSS, XML, XSLT,
or Dynamic Properties
Auto Load Sets how files are loaded. Available options vary by file type.
Auto Load JavaScript For more information on how JavaScript files are loaded, see Class
Files Loading in General Interface.
Auto Load CSS Files Manually The file is loaded programmatically with the
Dynamic loadResource() or loadInclude() method.
Properties
Files
It's not recommended to load CSS files
Mapping
programmatically, because they can be very slow to
Rules Files
load.
XML and
XSL Files
XML and XSL files are typically set to Manually. They can also be
loaded into cache using the XML URL property in the Properties
Editor palette. Rules files are typically set to Manually.
GUI The Auto Load option is disabled for GUI component files. You can
Component specify a GUI component file to automatically load when the
Files application initializes in the Initial Component field on the
Deployment panel of the Project Settings dialog.
Buttons
The following buttons are on the bottom right of the File Profile dialog:
Button Description
Cancel Cancels any changes and reverts back to the last saved version.
To open the IDE Settings dialog, choose Tools > IDE Settings.
For more in-depth discussion of some of these options, see Customizing the IDE.
Field Description
Output Specifies the character encoding to use when saving files, such as UTF-16. If
character this field is empty, the default is used, which is system-dependent. Click the
encoding Test button to verify that the specified encoding can be written and that it's
available on the system. For Internet Explorer, encoding behavior varies
according to Microsoft Windows updates and security settings, which might
need to be modified. UTF-16 and the default system encoding should be
supported regardless. If the test fails for other encodings, you might need to
enable the ADODB.Stream object. See "How to disable the ADODB.Stream object
from Internet Explorer" at
http://support.microsoft.com/default.aspx?kbid=870669 and reverse the
instructions to enable it.
Output line Specifies the line separator by operating system, such as UNIX, Mac OS, or
separator Microsoft Windows.
Instead Specifies the character encoding to use when saving XML files. This setting
encode XML overrides the XML declaration, if any. Check the Add character encoding to
files as XML declarations option to modify the encoding in the XML declaration.
Click the Test button to verify that the specified encoding can be written and
that it's available on the system. If this option isn't set, the setting in the
previous Output character encoding field is used. For Internet Explorer,
encoding behavior varies according to Microsoft Windows updates and
security settings, which might need to be modified. UTF-16 and the default
system encoding should be supported regardless. If the test fails, you might
need to enable the ADODB.Stream object. See "How to disable the
ADODB.Stream object from Internet Explorer" at
http://support.microsoft.com/default.aspx?kbid=870669 and reverse the
instructions to enable it.
Add Adds the encoding, specified in the Instead encode XML files as field, to the
character XML declaration. For example, if UTF-8 is specified, the XML declaration
encoding to would look like this: <?xml version="1.0" encoding="UTF-8" ?>
XML
declarations
Give DOM Specifies whether to assign focus to a new object in the Component Hierarchy
focus to palette and the work area after it's created.
newly added
GUI objects
Warn before Specifies whether to display a warning dialog before a file is dereferenced in
dereferencing the Project Files palette.
a project
resource file
Warn before Specifies whether to display a warning dialog before a component is recycled
deleting in the Component Hierarchy palette.
objects from
the
Component
Hierarchy
Open last Specifies whether to open the last project when General Interface Builder is
project when launched.
launching
General
Interface
Builder
Show Specifies whether to display the Welcome screen when General Interface
welcome Builder is launched. See Welcome Screen.
splash screen
on start
Snap-to Specifies the grid pixel size. Used when repositioning objects in the work area.
spacing To enable or disable the snap-to-grid feature, use the Toggle Snap-to Grid
button in the Component Hierarchy palette.
Field Description
Paths Panel
The Paths panel allows you to set paths for the workspace and HTTP base.
Field Description
Workspace A user home directory that contains your projects, custom add-ins and
prototypes, and your user settings for General Interface Builder. Browse to an
existing directory, create a new one, or accept the default workspace.
HTTP Base The path in the HTTP Base field is used when you select Project > Run Project
From HTTP. To use this feature, you must have an HTTP web server, such as
Apache, hosting both the General Interface installation directory and your
workspace directory.
WS Path If the relative path between General Interface installation directory and your
workspace directory aren't the same on the HTTP server as they are on disk, you
must enter the relative path to the workspace directory in the WS Path field.
Buttons
The following buttons are on the bottom right of the IDE Settings dialog.
Button Description
Cancel Cancels any changes and reverts back to the last saved version.
To open the Open Files dialog, choose File > Open or click the Open File button on the
Project Files palette. In some dialogs and tools, you can click the Browse button next to a field
that supports opening a file.
To open the Save File dialog, choose File > Save As or right-click a work area tab and choose
Save As. To open the Save File dialog in the XML Mapping Utility, click the Save As button
on the toolbar.
To open the Choose Folder dialog, click the Browse button next to a field in a dialog or tool that
supports choosing a folder.
Field Description
File or Folder Name The name of the file to open or save or the name of the folder to choose.
Buttons
The following buttons are on the top and bottom of the File Open, File Save, and Choose Folder
dialogs.
Button Description
Open Opens the selected file (Open Files dialog). Use Shift+click and Ctrl+click to select
multiple files.
Save Saves the file and closes the dialog (Save File dialog).
Choose Chooses the selected folder and closes the dialog (Choose Folder dialog).
To open the Project Settings dialog, choose Project > Project Settings.
Deployment Panel
Add-Ins Panel
Classpath Panel
Legacy Settings Panel
For more in-depth discussion of some of these options, see Modifying Project Settings.
Deployment Panel
The Deployment panel has settings for application deployment. For more information, see
Deploying Applications.
Field Description
Caption The text to display in the browser title bar while the application is running.
Namespace Each General Interface application has a single jsx3.app.Server instance. The
application namespace is a unique identifier for this single jsx3.app.Server
instance. All objects in a General Interface application are governed by this
server instance and uniquely located using the application namespace. The dot
symbol (".") is supported in the namespace. For example, eg.chart.APP.
Initial The path to the component to automatically load when the application
Component initializes at runtime. The path is relative to the project directory. For example,
components/appCanvas.xml.
Cancel Specifies whether to trap errors and display them in the System Log palette. If
Error checked, JavaScript errors are routed to the System Log palette in General
Interface Builder. If unchecked, JavaScript errors are routed to the browser.
Cancel Specifies whether to trap the right-click event. If checked, developers can
Right-Click replace the browser right-click menu with a custom menu. If unchecked,
right-click events are routed to the browser.
Mode The deployment mode for the deployed application used by the
jsx3.net.Service class. Live Mode An online mode where the application is
connected over HTTP/S to a back-end server, allowing access to online data.
When requests for data are made by the application, the request goes out over
HTTP/S and data is returned and rendered. Static Mode An offline mode where
the application isn't connected to a server. Data is static and is referenced using
static URLs stored in rules files. When a request for data is made by the
application, the request is routed to a local static XML document. That static
data is returned as if it came from a server and is rendered in the application.
Select this mode when developing an application offline or disconnected from
the server. This is useful when applications and back ends, such as web services,
are in development simultaneously or a back end is currently unavailable. See
Modifying Output Rules.
Body Hot Specifies whether to route key events that bubble up to the window from an
Keys application keyboard shortcut. If checked, the keyboard shortcut event bubbles
up to the HTML body element and is then sent to the application. Check this
option for deployment of standalone console applications. If unchecked,
keyboard shortcuts only function if the focus is in the General Interface
application. This option should be unchecked for deployment of non-console
applications that are a portion of a web page.
Overflow Determines how the application container behaves when movable objects, such
as dialogs and CDF drag masks, are moved off the edge of the container. Scroll
Movable objects cause the container to scroll. Expand Movable objects can leave
the container. Hidden Movable objects are invisible.
Default Specifies the locale of the localized application. Enter the two letter, ISO 639
Locale language code and the optional, two letter ISO 3166 country code. The format is
ll or ll_CC. For example, fr for French or fr_fr for French in France. See
Locale Keys. If this field is empty, the locale is determined by the browser. For
more information about localization, see Internationalizing and Localizing
Applications.
onLoad JavaScript code to execute when the application initializes. For example, you
Script might want to execute a main method, communicate with a server, create
controller objects by instantiating a controller class, or create the state of the
application. For more information, see Executing Code When the Application
Loads.
onUnload JavaScript code to execute when the browser window is unloaded. There are
Script several ways to unload a browser window, including closing the window,
refreshing the window, or navigating to another URL. The onUnload event
allows you to save user state and do any final cleanup before exiting. For more
information, see Executing Code When the Application Unloads.
Add-Ins Panel
Select which add-ins to load for the project, such as Charting or custom add-ins. Restart General
Interface Builder for changes to take effect. For more information on the Charting add-in, see
General Interface Component Guide.
Field Description
Classpath Panel
The project class path is used by General Interface to find custom classes that are dynamically
loaded by your application. This accelerates load time for your application. For setting class
paths, see Classpath Panel.
For more information on how classes are loaded, see Class Loading in General Interface. For
naming conventions for dynamically loaded classes, see Class Naming Conventions.
Field Description
Path The path to the custom classes. The class path is relative to the project directory. For
example, entering js/ as the path would load the specified classes in the workspace
/JSXAPPS/project_dir/js directory.
are allowed. |
Field Description
Project A version number for the project. When a resource in the project is accessed, the
Version string ?jsxversion=<project_version> is appended to the name of the resource.
This is useful for reloading cached files each time the project is modified.
Event Specifies the event protocol for the project. The options include 3.1 (default) and 3.0
Protocol (deprecated). In General Interface 3.0, certain public methods, such as
Tree.setValue(), generated model events, in this case the SELECT event. Such
methods have been deprecated in General Interface 3.1 or have had their behavior
changed so that model events aren't generated. In order to provide backward
compatibility, a per-project setting was introduced in 3.1 that determines whether
the project uses the 3.0 event protocol or the 3.1 event protocol. New projects use
the 3.1 event protocol by default. Setting the event protocol to 3.0 maintains the
behavior of General Interface 3.0.
Buttons
The following buttons are on the bottom right of the Project Settings dialog:
Button Description
Cancel Cancels any changes and reverts back to the last saved version.
Welcome Screen
The Welcome screen provides links to projects, documentation, Developer Network, and
General Interface Open Source Project.
By default, the Welcome screen displays when General Interface Builder is launched. The
Welcome screen can be enabled or disabled by toggling the Show at Startup option in the
Welcome screen or the Show Welcome Splash Screen on Start option in IDE settings (Tools >
IDE Settings > IDE Settings). The Welcome screen is also available from the Help menu.
Item Description
Create a New Launches the Create a New Project dialog. See Create a New Project Dialog.
Project
Documentation Provides links to User Guides and to API documentation in HTML format, if
installed. Documentation downloads in HTML and PDF format are also
available at http://www.generalinterface.org.
http://www.generalinterface.org
Show at Specifies whether to display the Welcome screen when General Interface
Startup Builder is launched.
To navigate in the Color Picker, use the arrow keys to move the slider, scroll through hex
values in the Hex field, and move between radio buttons.
Field Description
Color slider Use the slider to change color spectrum in the Color palette.
Preview The box at the lower right displays the currently selected color. Click in this box
color box to copy the hexadecimal (hex) color value to the clipboard.
S Specifies the color saturation, which is the intensity or purity of a specific hue.
(Saturation)
R (Red) Specifies the red portion of the RGB value. After specifying a value, press the
Enter key to view the updated hex equivalent.
G (Green) Specifies the green portion of the RGB value. After specifying a value, press the
Enter key to view the updated hex equivalent.
B (Blue) Specifies the blue portion of the RGB value. After specifying a value, press the
Enter key to view the updated hex equivalent.
Deployment Utility
Use the Deployment Utility to create a launch page for your application, a launch link, or an
inline div element. For more information, see Deploying Applications.
Command Description
XHTML If checked, XHTML markup is generated for the launch page. XHTML launch
pages are used for applications that run in XHTML pages, such as portlet
applications.
Create Creates the HTML or XHTML page for launching the deployed application.
Copy and paste the link into your HTML page and modify as desired. This hyperlink requires
the file GI_HOME \ shell.html to be deployed also.
Button Description
Copies the contents of the textbox to the clipboard which you can then paste into
your HTML page.
Copy and paste the inline DIV into your HTML page and modify as desired.
Button Description
Copies the contents of the textbox to the clipboard which you can then paste into
your HTML page.
Field Description
Find Enter the text string to search for in the active open text file in the project.
Case If checked, finds only exact case matches to the string entered in the Find field.
Sensitive
Regular If checked, JavaScript regexp syntax is supported in the Find field. For more
Expression information, see Help > Internet Resources > Regular Expressions Guide
(Mozilla).
Replace Enter a replacement text string for the found text in the active open text file in
the project.
Replace Replaces the found text string with the replacement string.
Replace Replaces all occurrences of the text string with the replacement string.
All
To open the XML Mapping Utility, choose Tools > XML Mapping Utility or File > New >
Mapping Rule.
When you open the XML Mapping Utility from the Tools menu, the first panel allows you to
select the file(s) to open.
WSDL Select this radio button if you are using a WSDL as the source
document for generating the mapping rules.
XML/XHTML/Schema Select this radio button if you are using a XML, XHTML, or Schema
as the source document(s) for generating the mapping rules.
URL If WSDL is selected, choose the URL for the WSDL to be used for
generating the mapping rules. If XML/XHTML/Schema is selected,
enter the URLs for the outbound and inbound document(s).
Documents that are created are "outbound," while documents that
are processed are "inbound."
For more information, see Choosing the File for the Rules File Starting Point.
Radio Description
Button
Original Displays the original Schema or XML node used to generate the selected rule.
Schema
Source
Rule Displays name-value pairs for the selected rule. Many of the fields in the Rule
Node Profile panel are editable. Typically, you would modify the node name and the
Profile target namespace.
Button Description
Display When the Original Schema Source radio button is selected in the Rule Profile panel
WSDL and the WSDL node is selected in the Rules Tree panel, this button is available in
Source the Rule Profile panel. Depending on the size of the WSDL, displaying the WSDL
might take some time.
Field Description
Abstract If the value is 1, this rule is abstract and only exists in the rules tree, not in the
final XML message. An abstract rule can be used to reorganize the rules tree
without affecting the structure of the XML message.
Data For encoded messages, the data type to encode, such as string, boolean, decimal,
Type and so on.
Data For encoded messages, the namespace for the data type.
Type NS
Input URL to the input source file used to generate these rules. The input source file
Source could be a WSDL, XML, XHTML, or Schema file.
Node The name of the node as it appears in the XML message that is created or
Name processed.
Operation The name of the operation as defined in the input source file.
Name
Rule ID Unique ID (jsxid) assigned by the General Interface system when the rule was
created.
Rule The type of rule, such as WSDL, transaction, service, operation, input, output,
Type element (E), attribute (A), complex type (C), and CDATA (D). Each rule type has
an associated icon in the rules tree. For icon definitions, see Table 13.
Simple Set the value to 1 to denote that this rule is a simple type (
Type http://www.w3.org/2001/XMLSchema). Simple types include string, int, href and
so on. For definitions of simple types, see the XML Schema at
http://www.w3.org/2001/XMLSchema.
Source XPath statement that points to the location of the node in the source document
Path that was used to generate the rule. Maintains the binding between the source
document and the rule node.
Target If set to a specific URI, the node name is auto-prefixed (QName) to designate the
target namespace. For example, <jsx1:zipcode>.
Settings Panel
The fields displayed in the Settings panel on the right side of the XML Mapping Utility depend
on the type of rule selected in the Rules Tree panel. The type of rules include the following:
Operation Rules
Input Rules
Output Rules
Message Rules
For information on how to use the Settings Panel, see Working in the Settings Panel and
Communicating with a Web Service Tutorial.
Operation Rules
When an operation rule is selected in the Rules Tree panel, the following fields are displayed in
the Settings panel.
Endpoint This is the URL for the service to contact. It can be absolute (http/https)
URL or relative (/services/address.asmx). To override this setting at
runtime, call setEndpointURL on the Service instance.
HTTP Each HTTP request can send different types of information. For
Headers example, the HTTP request can send any of the following: an XML
document (POST), a URL overloaded with data of its own (GET or
POST), or information about the content and purpose of the request
itself. The HTTP headers listed in this field are automatically generated
during the initial parse. If additional headers are needed, you can add
them statically to this field. You can also add them at runtime on the
Service instance by calling setRequestHeader for each additional header
that should be added. Other headers not listed are also sent, including
the content-length and any cookies used by the service.
Input Rules
When an input (request) rule is selected in the Rules Tree panel, the following fields are
displayed in the Settings panel.
Field Description
Stub URL Typically used in conjunction with the Stub Path field to support SOAP-based
web services. When SOAP is used, each request document is encapsulated by
a SOAP Envelope. The XML Mapping Utility treats the Envelope as a static
document into which the actual request is placed. This document is generic
enough to encapsulate the majority of SOAP messages. If this default
document does not contain enough information, you can specify the URL for
a static stub of your own. This value can be updated at runtime using the API
calls, setOutboundStubURL or setOutboundStubDocument.
Stub Path Used in conjunction with the Stub URL field. Type a valid XSL query that
describes where to place the generated document in the Stub document. This
value can be updated at runtime using the API call, setOutboundStubPath.
onBeforeSend JavaScript statements entered in this field execute immediately before the
request message is sent. This script executes in context of the Service instance.
This means that the keyword, this, refers to the Service instance. For
example, if you want to output the XML request to the System Log before
sending it, you would enter:
jsx3.log(this.getOutboundDocument().getXML());
Output Rules
When an output (response) rule is selected in the Rules Tree panel, the following fields are
displayed in the Settings panel.
Field Description
Stub URL Enter the URL for a valid XML document (the typical response) when
running the XML Mapping Utility in static mode (offline). The static mode
allows you to test against a typical service response. This is useful in
situations where the service isn't built yet or is inaccessible. To change the
mode to static, choose Project > Project Settings > Deployment. This URL
can also be set at runtime using the API call, setInboundURL. For more
detailed information, see Modifying Output Rules.
onAfterReceive JavaScript statements entered in this field execute immediately after the
response message is received and before the mappings are applied. This
script executes in context of the Service instance. This means that the
keyword, this, refers to the Service instance. For example, if you want to
output the XML response to the System Log each time the service responds,
you could write: jsx3.log(this.getInboundDocument().getXML()); For
other examples, see onAfterReceive.
Message Rules
When message rules are selected in the Rules Tree panel, the following fields are displayed in
the Settings panel. Message rules, which are children of input and output rules, include
complex type, element, attribute, and CDATA rules.
Mappings The Mappings table is where the actual work is done. When a
request message is generated or a response message is
processed, each mapping listed in this table is run sequentially
for the given rule. Although different mapping types exist, all
mapping types provide a map between objects in the application
(textbox, JavaScript variable, CDF attribute, and so on) and rules
in the rules tree. For more information on mapping, see
Communicating with Data Services.
NODE Maps to a node in the Local Data Cache palette. Type the cache
document name, two colons, and a valid XSL Query. For
example, myDocument:://recordjsxid=12.
DOM Maps to a GUI object in the General Interface DOM. Enter the
object name.
CDF Queries for or creates a CDF document in the Local Data Cache
Document palette. Enter the CDF document name.
CDF Record Queries for or creates a CDF Record as a child of the current
CDF record context. The Path/Value field is not required but can
be used to support recursion or hand off processing to another
rule. For example, if there is another rule in your mapping rules
file that has a CDF Record mapping, you can enter the jsxid for
that rule. To find the jsxid, select the rule that you wish to call
and click the Rule Node Profile radio button.
CDF Queries for or creates a CDF attribute on the nearest CDF record
Attribute ancestor. Enter the attribute name, such as jsxid, jsxtext, price,
and so on.
Restrictions When Schema or WSDL are used as the input for the XML
Mapping Utility, any restrictions appear in the Restrictions
table. You can also add additional restrictions on a rule. For
example, you might restrict user input to be equal to dog or cat.
To restrict such input, you would add two new enumeration
restrictions to the rule: one for cat, the other for dog. At runtime,
these restrictions can be used to validate the request document
as it's created node-by-node. For more information about what's
published when a node value doesn't adhere to its restrictions,
refer to the ON_INVALID subscription for the Service class. For
more information, see Restrictions.
minInclusive Specify a minimum inclusive value. For example, the node value
must be greater than or equal to the specified value.
Field Description
Repeat As long as the JavaScript code in this field evaluates to true, the rule and all
When descendant rules are run again. The JavaScript function is used to create and define a
collection from a single node. The collection is added as nodes in the XML message
to the server. Don't enter true in this field, because it results in an infinite loop. The
Repeat When field is only applicable to outbound (input) messages. It's typically
used by mapping rules that convert a JavaScript array into an XML Node-set in the
outgoing message. Conceptually, this feature is similar to a do-while loop, where
execution will happen at least once and continue as long as the while (Repeat When)
statement is true. For examples, see Repeat When. Also note that CDF mappings
automatically repeat when necessary. For more information on CDF GUI
components, see Mapping Response Data to CDF GUI Components.
Mapper Log
The Mapper Log displays information about the outcome of parsing the starting point
document and testing mappings.
For more information, see Mapper Log and Mapper Log Toolbar.
Field Description
Text Displays the XML Mapping Utility log messages according to the selected log level.
area Use the Adjust Log Level button to select a log level.
To use the Test Interface Tool, click the Test button on the Rules Tree panel toolbar in the XML
Mapping Utility.
Create Panel
Send Panel
Receive Panel
Apply Panel
Each panel of the Test Interface Tool contains this drop-down list:
Field Description
Create Panel
Mappings for the outbound message display on this panel.
Send Panel
The outbound message displays on this panel.
Field Description
HTTP Header content for the message. The header text can be edited.
Headers
Method Method for contacting the Service. Choose from POST, GET, PUT, and DELETE.
The most common are GET and POST.
Receive Panel
The Service response displays on this panel.
Field Description
Apply Panel
The inbound mappings display on this panel.
To open the XML/XSL Merge Tool, choose Tools > XML/XSL Merge Tool.
Field Description
URL The location of the XML or XSL file, either on an accessible file system or on a
web server.
Cache The name of the XML or XSL file in browser cache, as displayed in the Local
Data Cache palette.
Script JavaScript code that produces an XML document or a node in an XML document
as output.
Source XML or XSL code typed directly into the tool dialog. If URL, Cache, or Script is
used to specify the XML or XSL source, this field displays the file contents. In the
case of XSL, modifications can be made before the merge operation.
Merge Merges the XML document with the XSLT filter document and displays the
Documents results.
Rendered Displays the result of the merge operation as rendered XML or HTML (as it
Output would appear in a browser).