List Provider - Sample Code

The sample ListProvider in this example does the following:

 

The sample code demonstrates

 

The sample code provides functionality for requirements such as:

 

Setup

This sample code needs the following to run:

 

About the ExtFrameworkListProvider Rulebase

The rules is not relevant for this sample, it is the attributes that the List Provider need to provide list options for

The attributes relevant to this example:

Global

 

About the DERBY SQL database

AU_STATES

ID

STATE_SHORTNAME

STATE_FULLNAME

 

POLITICAL_ALIGNMENTS

ID

PA_NAME

 

About the Derby List Provider plugin

To setup this scenario:

  1. Create the SQL Database. It doesn't have to be DERBY, but that is what the source code is set up for.
  2. Populate the AU_STATES and POLITICAL_ALIGNMENTS table with dummy data. This data will be used to populate the state and political_alignment listboxes during the interview.
  3. Create the ExtFrameworkListProvider rulebase in Oracle Policy Modeling.
  4. Create a Screens file and add “political_alignment” and “state” listbox input controls.
  5. Build the rulebase.
  6. Copy the rulebase .zip file from the project output directory (for example, C:\projects\ExtFrameworkListProvider\Development\output) to the rulebase folder in the Web Determinations (for example, <webroot>\WEB-INF\classes\rulebase)
  7. Copy the code for the DerbyListProvider plugin (you may need to modify the database connection details)
  8. Compile and JAR the DerbyListProvider (you may need class files for your specific database implementation)
  9. Install the JAR file on the Web Determinations. More info in article: Create a Plugin
  10. Run a Web Determinations Interview

How the DerbyListProvider works

The DerbyListProvider is always called when a List input control is displayed during the Web Determinations Interview. The DerbyListProvider allows the Web Determinations to use the default list items on the List input control (default list items - the list of values provided by the rule author) unless the Attribute associated to the List input control is 'states' or 'political_alignment'. The DerbyListProvider returns a 'null' object to let the Web Determinations know to use the default list items.

If the Attribute of the List input control is 'states' or 'political_alignment', DerbyListProvider accesses the DERBY database, access either the AU_STATES or POLITICAL_ALIGNMENTS table (depending on the Attribute), and gets the list items. It then constructs a List of ListOptions from the data retrieved. The DerbyListProvider returns the list of ListOptions, which tells Web Determinations that it should use this list as the items in the List input control instead of the default list.

Source Code

 

DerbyListProvider.java