| Samples > Rule Team Server Authoring Extensions > How to Publish a Custom Value Editor |
How to Publish a Custom Value Editor |
PREVIOUS NEXT |
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.
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 of this sample include:
To install this sample through the Samples Console:
teamserver > servervalueeditor.
repack command to compile and repackage the application into a new deployable file.
run command to register the value editor and deploy the new application.
[EARDeployer] Started J2EE application.)
This sample can only be opened and run in the Samples Console.
To open and run the sample:
http://localhost:8080/teamserver.
valueeditor-rules project.
AA"
offer rule in the valueeditor-rules project and click on #BFGHFDF in the condition part of the rule.
This sample is located in <InstallDir>/teamserver/samples/servervalueeditor.
FilterComponent.java - The web component class that supports the filter editor. It extends IlxWComponent and is composed of IlxWTextField, an IlxWList and an IlxWLabel. It redefines the printComponent method and manages the filter behavior.
FilterTokenActionManager.java - The manager class that instantiates the filter. It extends IlrWDefaultTokenActionManager which is a container that pops up a window with OK and Cancel buttons. It instantiates the FilterComponent with a FilterDataProvider (FilterDataProviderImpl)
FilterValueEditor.java - Editor class that instantiates the manager. It extends IlrWValueEditorComponent.
getValue and setValue - Used for persistence purposes.
getEditorComponent - Returns the web component used by the value editor. It is called each time the component is displayed.
FilterDataProvider.java - A simple interface used by the filter component to get values.
FilterDataProviderImpl.java - A very simple implementation of the FilterDataProvider.
FilterValueTranslator.java - A class to define textual representation translation into rules.
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.
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.
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:
valueditor). In this sample, the identifier is webui.editor.sample.myeditor.editor
valueDescriptor and DecoratedValueDescriptor.prefix)
valueTranslator). In this sample, the identifier is servervalueeditor.FilterValueTranslator
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.
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.
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.
To rebuild this sample:
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |