Custom value editor sample details
You use Decision Center to run this sample.
Running this sample
To open and run this sample:
Sign in to the Decision Center Enterprise console: http://localhost:<PORT>/teamserver.
Username: rtsAdmin
Password: rtsAdmin
Make sure that Work on a decision service is selected. Switch to the Value Editor Service project.
To see the new value editor, compose a new rule:
Click the Compose tab, select Action Rule, and then click OK to confirm.
Go to Step 2: Content.
Click . Then click Select <a promotional offer>.
The editor opens.
Enter a pattern such as “AA”. Decision Center displays all promotional offers that contain this pattern.
Click OK.
Click Cancel; you do not have to save this rule.
Go to the Explore tab and edit the offer rule.
Click #BFGHFDF in the condition part of the rule. You can see that your custom value editor is working correctly, because the display changes for each entry you select.
Rebuilding this sample
To rebuild this sample:
In the Samples Commands view, navigate to .
Double-click clean.
Double-click build. Rule Designer builds the custom JARs.
Double-click repack. Rule Designer repackages the teamserver application to include the custom JARs.
Double-click run. Rule Designer deploys the repackaged application.
How this sample works
For the purpose of this sample, the project Value Editor Service has a BOM that contains a class (PromotionalOffer) with some custom properties defined.
You use the properties to:
Associate the custom value editor graphical component with the BOM class (valueditor). In this sample, the identifier is sample.myeditor.editor.
Define the processing, persistence, and representation of data values managed by the custom value editor in the rule editors and how the value editor integrates with the rule editors (valueDescriptor and DecoratedValueDescriptor.prefix).
Define how the textual representation of its data values are translated in the rules (valueTranslator). In this sample, the identifier is servervalueeditor.FilterValueTranslator.
For more information, see Sample: Custom value editor.
You must declare a mapping between the value editor identifier and the value editor class in Decision Center. To do this, you use the set-config-param target, which registers the webui.editor.sample.myeditor.editor key to the fully qualified name of the value editor class servervalueeditor.FilterValueEditor. In the sample, this is done by the run target.
After you write your rule, you must associate a value translator to your data type (BOM class) to help Decision Center convert your rule to its IRL representation. Decision Center translates the promotional offer code into IRL by instantiating the PromotionalOffer class. You can examine the FilterValueTranslator.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 have to provide only the class in your custom jar file.
The repack Ant target in the build.xml file uses the repackage-war Decision Center Ant task to rebuild the teamserver application to include the custom JARs containing the value editor and the value translator.
Source files
This sample is located in <InstallDir>/teamserver/samples/servervalueeditor. It contains the following files in src/servervalueeditor:
FilterComponent.java: The web component class that supports the filter editor. The class extends IlxWComponent and is composed of IlxWTextField, an IlxWList, and an IlxWLabel. It redefines the printComponent method and manages the filter behavior.
FilterDataProvider.java: A simple interface used by the filter component to retrieve filter items.
FilterDataProviderImpl.java: A simple implementation of FilterDataProvider.
FilterTokenActionManager.java: A manager class that instantiates the filter. It extends IlrWDefaultTokenActionManager, which is a container that displays a window with the OK and Cancel buttons. The class instantiates FilterComponent with FilterDataProvider (FilterDataProviderImpl).
FilterValueEditor.java: An editor class that instantiates the manager. It contains FilterTokenActionManager.java, the manager class that instantiates the filter. It extends IlrWValueEditorComponent, which is a container that displays a window with the OK and Cancel buttons. The class instantiates FilterComponent with FilterDataProvider (FilterDataProviderImpl).
The class inherits the following methods:
getValue and setValue, which are used for persistence purposes.
getEditorComponent, which returns the web component used by the value editor. The method is called each time the component displays.
FilterValueTranslator.java: A class to define textual representation translation into rules.
The web components in this sample help 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 for business rules for more information.
You can also view and modify the sample source files in Rule Designer. To import the sample into your workspace, click the Import projects link in the Samples and Tutorials view.