Create a Custom Screen example

Create a Custom Screen example

This example demonstrates how to implement a custom screen plugin for Web Determinations. For more general information on constructing and debugging custom screen plugins, see Create a Custom Screen.

In our example, we will have a custom screen plugin replace a Web Determinations screen by calling out an external application.

Step 1. Build the rulebase

The first step is to create a simple rulebase with a single base-level attribute and a single question screen for that attribute.

  1. In Oracle Policy Modeling, choose File | New Project... and name the project "TestCustomScreen".
  2. Add a new properties file.
  3. Add the following global attributes to the properties file:



  4. Add a new Word document and write the following rule:

    the interview is complete if

    the user says the interview is complete

  5. Compile the rule and close the document, returning to Oracle Policy Modeling.
  6. Add a new screens file.
  7. Open the assessment summary screen, and add the "the interview is complete" attribute as the goal:



  8. Also in the screens file, add a new question screen. Edit the screen to add the base-level attribute "the user says the interview is complete" as an input control:

 

Now we want to test that the rulebase is working correctly.

  1. In Oracle Policy Modeling, choose Build | Build and Debug | With Screens.
  2. A Web Determinations interview should open, in which you can determine if "the interview is complete" by whether the user says the interview is complete:





 

You should now have a functioning rulebase. If your rulebase is not working correctly so far, you should fix any problems before proceeding to the customization steps.

Step 2. Build a custom screen plugin

The next task is to build the plugin. Our plugin has two classes:

Note that the Java source code is provided but the .NET source code should be very similar.

To build the custom screen plugin:

  1. Copy the java files found in <runtime_zip_dir>\examples\web-determinations\custom-screen\src and compile them to a JAR file.
  2. Tell your java compiler how to find the needed Oracle Policy Automation dependencies, as detailed in Create a plugin. Call the resulting JAR file, ExampleCustomScreen.jar.
  3. Copy the ExampleCustomScreen.jar file you have created to your plugins directory, where Oracle Web Determinations can find it. If your rulebase is at <...>\TestCustomScreen, the correct directory for your plugin is <...>\TestCustomScreen\Release\web-determinations\WEB-INF\classes\plugins. If the Release directory does not exist, Build and Debug your rulebase once to create it.
  4. Build and Debug with Screens again and your plugin should now be loading; but it will display an error page once you click on the goal. This error is shown because the external web application where the user is supposedly to be redirected does not yet exist.

Step 3. Create the external web application

The last step is to create a simple servlet application where the user will be redirected by the custom screen. The servlet code can be found in <runtime_zip_dir>examples\web-determinations\custom-screen\ExampleCustomScreenWebApp. The servlet has two classes:

To create the external web application:

  1. Create and test the servlet.
  2. Package the application as a WAR file then deploy it to the same server where Web-Determinations is running.
  3. Restart the server; your custom screen should now be working.
  4. Start the interview. Notice that when you click on the goal, you are now redirected to the external web application.

Custom Screen Source Code

Examples containing the source code can be found at <runtime_zip_dir>\examples\web-determinations\custom-screen\src.