Using Custom Functions

Once you have created a custom function class, you will need to make it available to Presentation Designer for use. You will also need to decide whether you want to make it available to a specific project, or to all projects created using Presentation Designer.

Adding a Custom Function to a Specific Project

To add your custom function to a specific project, and make it available to that project only, when you select a source for a function from the Event editor, all of the class files and any subfolders within that directory are loaded to determine whether the class implements IFunction, and is therefore a function object.

You can save your custom function class files in the classes subfolder of your project folder, or specify the folder that contains your functions when you associate functions with events. Any custom functions found are then displayed in the Select Function dialog box.

Caution If a function class placed in the \classes folder for a project contains a reference to an external JAR file, you must add a dependency for the external JAR file, or folder containing the classes referenced, in the libraries.xml file. The JAR files and folders listed as dependencies are not exposed in the Select Function dialog box. They are added to the classpath of functions used from a function library and published with any application in which they are used. If you attempt to publish an application in which a class is used that contains a reference to an external JAR file that cannot be found, you will receive an error message, and the application will not be published.

Following are the attributes for the dependency elements within libraries.xml:

Attribute Description
src Required. Name of a JAR file, or name of a folder containing function classes, to which a dependency is created.

Function Libraries

Custom function classes are grouped into libraries. A function library can contain multiple functions, and functions can be added to a library as either a JAR file or a class package. However, only one format can be used for all the functions contained in that library, and each library name must be unique within the current installation of Presentation Designer.

Function libraries are defined in an XML configuration file, libraries.xml. This file is created during the installation of Presentation Builder. It contains definitions for the Math and String function libraries included with Presentation Designer, and is installed to the C:\Program Files\Attachmate\EAI\PresentationDesigner folder by default.

When you add a custom function to a library, you will need to edit the libraries.xml file and create a new library entry. The libraries.xml file includes comments that will guide you through the process of adding a new function library entry and providing values for your custom function library. When you add custom functions to a custom function library, those functions can be accessed globally from all projects created using Presentation Designer.

Note After you have saved the modified libraries.xml file, to make your custom functions available through the Event editor, you must restart Presentation Designer.

Following are the attributes for the library elements within libraries.xml:

Attribute Description
name Required. The name of the library as it is displayed in the Select Function dialog box in Presentation Designer.
type Optional. Specify standard or user. (Default: user.)
platform Optional. (Default: Java.) Reserved for future use.
package Optional. If specified, only objects from the specified package are displayed in the Select Function dialog box. (Default: all packages.)
src Required. The name of a JAR file, or the name of a directory. The specified JAR or directory is added to the classpath.
publish Optional. Specify true or false. If true, the JAR files in the library are published with the application in which they are used. (Default: false.)
reload Optional. Specify true or false. If true, the designer reloads functions each time they are accessed. If you are modifying your custom functions in your IDE while interacting with them in Presentation Designer, specify true. (Default: false.)

Categorizing Functions

Presentation Designer uses information about the JAR files, libraries, and functions to display them in the Event editor. When you browse for a function and select a class, Presentation Designer builds a list of available functions first, without actually loading each bean class (the class for a function is loaded only after you choose that function). The library configuration file, libraries.xml, together with the manifest files, is used to retrieve information from the JAR files. If the JAR file is not in the default location for functions classes, you must add a dependency for the JAR or folder containing the JAR in the libraries.xml file.

Related Topics
Bullet Custom Functions, Overview
Bullet Creating Custom Functions
Bullet Installing Custom Functions
  Attachmate