Samples > Rule Team Server Authoring Extensions > How to Publish a Custom Value Editor

This sample shows how to plug a custom value editor inside Rule Team Server's web-based Guided Editor. ILOG JRules provides some editors for values such as Date, but it also allows you to create your own value editors. The same customization is available for both Rule Studio's Intellirule Editor and Guided Editor.

In this sample, we will define an editor to help filter out large numbers of items. The editor looks like this.

images/servervalueeditor.png

This list is updated as you type a text pattern, filtering out those list entries that do not match the pattern you are entering.

Key Features

Key features of this sample include:

Installing this Sample

To install this sample through the Samples Console:

  1. Go to the Samples Console and locate the sample teamserver > servervalueeditor.
  2. Check that the Samples Server is started. For information on how to start and stop the Samples Server, see Stopping and Restarting the Samples Server from the Samples Console.
  3. Execute the repack command to compile and repackage the application into a new deployable file.
  4. Execute the run command to register the value editor and deploy the new application.
  5. Wait for the Java EE application to start before continuing. (The server trace displays the message: [EARDeployer] Started J2EE application.)

Running this Sample

This sample can only be opened and run in the Samples Console.

To open and run the sample:

  1. Sign in to Rule Team Server: http://localhost:8080/teamserver.
  2. Username: rtsAdmin
    Password: rtsAdmin
  3. Switch to the valueeditor-rules project.
  4. To see the new value editor, compose a new rule:
    1. Click the Compose tab, select Action Rule, and then click OK to confirm.
    2. Go to Step 2: Content.
    3. Click Select an action > Set the promotional offer of the purchase to a promotional offer.
    4. Click Select a promotional offer.
    5. Enter a pattern such as "AA"
    6. Click OK.
  5. To test the custom value editor, edit the offer rule in the valueeditor-rules project and click on #BFGHFDF in the condition part of the rule.

Source Files

This sample is located in <InstallDir>/teamserver/samples/servervalueeditor.

Web components used in this sample allow you to write Java code instead of JavaScript and provide an AJAX presentation of your editor (which allows sub-requests to the server). See web components documentation for more information.

Highlights

There are several parts to understand when you want to use a new value editor in Rule Team Server, as described in the following sections.

Setting Business Object Model Custom Properties

For the purpose of this sample, the project valueeditor-rules already has a BOM that contains a class (PromotionalOffer) on which some custom properties have been defined. If you have installed Rule Studio, you can import and browse the valueeditor-rules project, and navigate to the PromotionalOffer class.

The properties are used to:

Registering the Value Editor Class

You need to declare a mapping between the value editor identifier and the value editor class in Rule Team Server. This is done by the set-config-param target, which registers the key webui.editor.sample.myeditor.editor to the fully qualified name of the value editor class servervalueeditor.FilterValueEditor.

This target is called by the run target.

Registering a Value Translator

Once your rule is written, you have to associate a value translator to your data type (BOM class) to help Rule Team Server convert your rule to its IRL representation. The promotional offer code is translated into IRL by an instantiation of the PromotionalOffer class. You can examine its translateValue method.

In this sample, this is done with FilterValueTranslator. The mapping between the BOM member and the FilterValueTranslator class is done by BOM custom properties, so that you only have to provide the class in your custom jar file.

Application Packaging

A new application containing custom jars must be built and deployed. The value editor must be packaged in the WAR. The value translator must be packaged in the EAR/lib. To package the value translator, use the repackage-ear Ant target.

Rebuilding this Sample

To rebuild this sample:

  1. Execute the clean command.
  2. Execute the build command.

Related Concepts

Custom BOM Properties

Related Tasks

Managing BOM Value Types

Related Reference

Web Components

Related Samples and Tutorials

How to Use a Custom Value Editor in the Rule Editor