Create a Custom Control

Create a Custom Control

The following information describes the steps for creating a custom control, installing it onto a Java webserver, and running the custom control. While this describes a Java implementation, similar steps can be followed for .Net.

For a generic background on how to construct a plugin, see Create a plugin.

Assets and information needed

The following are information that will be referred to in the steps below:

Web Determinations plugin folder - this is where the Web Determinations webserver will pick up the plugins. The user needs to place the plugin packages (.jar for Java).

 

Web Determinations templates folder - this is where Web Determinations will look for Velocity templates from which it renders the HTML code served to an end-user.  Custom controls generally require a matching template to be added to this folder.

 

Web Determinations library jars

Steps

To develop a custom control:

  1. Determine the purpose of your control.  If it is attached to a rulebase attribute (even if it is a read-only control with no input), you want an InputCustomControl.  If it is a display which gets information from other sources, it is a plain CustomControl.
  2. Planning -- which default controls will your custom control be replacing?  How will it know?  The custom control provider can use any available information for each control on each screen, to determine whether it will insert a custom control.  Common techniques are to examine the control label set by the screen author in Oracle Policy Modeling (for custom controls which are meant to be used only in a single location) or custom properties set on the control (for more generic controls that could be used more than once.).
  3. If you are using a Java IDE - set it up with a Java project and load the Web Determinations library jars as Java libraries. The Web Determinations library jars have Javadoc, which will make it much easier when using Web Determinations Java objects in the jars.
  4. Create a java class for the custom control provider in the new Java project, and implement the CustomControlProvider interface and its methods in the new Class.  Each time a new user begins a session, the CustomControlProvider will be examining an InterviewSession to determine whether its custom controls are relevant to this session.  More information about using rulebase model and instance data in the InterviewSession object can be found in Understanding the InterviewSession.
  5. Create a java class for the custom control itself, and implement the CustomControl or CustomInputControl interface and methods.
  6. Create a velocity template from which the control's HTML code will be rendered.

To install the Event Handler:

  1. Package the custom control, custom control provider, and any other required classes in a .jar file.
  2. Deploy the jar file into the Web Determinations plugin folder, together with any other libraries that were required (except the Web Determination library jars - they are already in the 'lib' folder).
  3. Restart the J2SE server to enable the new plugin.

Test the plugin:

  1. The first step to check is if it was recognized and loaded by the Tomcat server. The Web Determinations web application prints out data about Plugins that were loaded into the runtime successfully. Any errors when loading a Plugin is also printed out. Check the webserver's output file (for example, stdout.txt for Tomcat).
  2. The next step is to check if the Plugin is registered. The getInstance method will be called each time a Web Determinations interview is started (that is, rulebase and locale have been selected). If you are having trouble getting the plugin registered, ensure that your plugin getInstance method simply returns a new CustomControlProvider object.
  3. Finally, if the plugin is loaded and registering correctly, test its functionality.

Walkthrough Examples

The Benefit Code example walks through constructing a rulebase and a custom control which allows the user to enter a single attribute using a two-part control, demonstrating how the velocity template and the custom control plugin communicate to render arbitrary HTML using data from the application.

The Calendar Date Control example walks through using an example rulebase, a custom property, a calendar written in javascript, a custom input control plugin and velocity templates to demonstrate how the date entry could be customized to use a calendar.

This Filtered Dropdown selection list example demonstrates how to create a filtered dropdown list (FilterListCode) which, when a user starts typing, only displays the relevant options.