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.
In Oracle Policy Modeling, choose File | New Project... and name the project "TestCustomScreen".
Add a new properties file.
Add the following global attributes to the properties file:
Add a new Word document and write the following rule: the interview is complete if the user says the interview is complete
Compile the rule and close the document, returning to Oracle Policy Modeling.
Add a new screens file.
Open the assessment summary screen, and add the "the interview is complete" attribute as the goal:
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.
In Oracle Policy Modeling, choose Build | Build and Debug | With Screens.
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:
ExampleScreenProvider.java the class that Web Determinations will look for each time a screen is to be displayed. It determines if the screen to be displayed will be replaced by a custom screen. In our example, the Stand-In screen will be replaced by the custom screen, ExampleScreen, if the screen ID is "TestCustomScreen" - which is the public ID of the question screen we added.
ExampleScreen.java the custom screen itself. This custom screen redirects the user to an external web application.
Note that the Java source code is provided but the .NET source code should be very similar.
To build the custom screen plugin:
Copy the java files found in <runtime_zip_dir>\examples\web-determinations\custom-screen\src and compile them to a JAR file.
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.
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.
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:
ExternalProcessingSystem.java the servlet that will be displayed. This screen contains two buttons: one will cause the user to return to Web-Determinations, and the other button keeps the user on the current screen while simulating passing of data to Web-Determinations.
web.xml the servlet configuration.
To create the external web application:
Create and test the servlet.
Package the application as a WAR file then deploy it to the same server where Web-Determinations is running.
Restart the server; your custom screen should now be working.
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.