26 Using Declarative Components and Task Flows

Learn how to use different Oracle Business Rules declarative components and task flows to develop high-performance, interactive, and multitiered applications that are also easy to maintain. It describes how to use the Oracle Business Rules Editor declarative component and the Oracle Business Rules Dictionary Editor declarative component and task flow. It also describes how to localize the ADF-based web application.

26.1 Introduction to Declarative Components and Task Flows

Declarative components are reusable, composite user interface (UI) components that comprise other existing Application Development Framework (ADF) Faces components.

Consider an application that contains multiple JSF pages. On a particular page, a set of specific components is used in multiple parts of that page. In this scenario, if you make any changes to any of the components in the set, you typically must replicate the changes in multiple parts of the page. This approach makes it difficult to maintain the consistency of the structure and layout of the page. However, by defining a declarative component that comprises the given set of components, you can reuse that composite declarative component in multiple places or pages. Declarative components, thereby, save time and ensure integrity across pages because when you make any changes to the components, the JSF pages using them automatically get updated.

ADF task flows are reusable components that provide a modular and transactional method in specifying the control flow in an application. You can use a set of reusable task flows as an alternative to representing an application as a single large JSF page flow, thereby providing modularity. Each task flow contains a part of the entire navigational plan of the application. The nodes in a task flow are called activities. Apart from navigation, task flow activities can also call methods on managed beans or call another task flow without invoking any particular page. This facilitates reuse because business logic can be invoked independently of the page being displayed.

26.2 Introduction to the Oracle Business Rules Editor Declarative Component

Get an overview of the Oracle Business Rules Editor declarative component.

Learn how to create and run an application using the Rules Editor component, and then deploy the application. Also get an overview of the supported tags and the localization process for the application.

26.2.1 Using the Oracle Business Rules Editor Component

The Oracle Business Rules Editor is a declarative component that can be embedded in any ADF-based web application. The component renders the user interface for rules editing and handles all events associated with rules editing. The Rules Editor uses the Rules SDK2 API to create and edit rules.

Note:

You should not confuse the Rules Editor with the Rules Dictionary Editor. The Rules Editor is used to edit rules inside a specified ruleset. In fact, the Rules Editor is embedded within the Rules Dictionary Editor. For more information about the Rules Dictionary Editor, see Introduction to the Oracle Business Rules Dictionary Editor Declarative Component.

Using the Rules Editor, you can create, delete and edit the general rules, verbal rules, and decision tables that are part of a single ruleset. You are required to specify a RuleSetModel object, which is a wrapper around the Rules SDK ruleset object, as a parameter to the Rules Editor component. If multiple rulesets are required to be modified, multiple Rules Editor components must be instantiated, one for each ruleset.

The Rules Editor component performs the following functions:

Note:

After all the edits are done, the component user is responsible for saving the ruleset.

26.2.2 How to Create and Run a Sample Application by Using the Rules Editor Component

This section lists the steps for creating and running a sample application by using the Rules Editor component.

The prerequisite for using the Rules Editor component to create ADF-based web applications is having a running installation of Oracle SOA Suite and Oracle JDeveloper on your computer.

To create a sample application by using the Rules Editor:

  1. Open Oracle JDeveloper.

  2. From the File menu, select New.

  3. Select ADF Fusion Web Application to create a new application as shown in Figure 26-7.

    Figure 26-7 Creating Fusion Web Application

    Description of Figure 26-7 follows
    Description of "Figure 26-7 Creating Fusion Web Application"
  4. Enter a name for the application in the Application Name field, for example, useRulesDCApp, and click Next as shown in Figure 26-8.

    Figure 26-8 Creating a Generic Application

    Description of Figure 26-8 follows
    Description of "Figure 26-8 Creating a Generic Application"
  5. Use the default for everything else.

  6. Click Finish.

  7. Right click ViewController project and select Project Properties.

  8. Select Libraries and Classpath from the menu on the left.

    1. Click the Add Library button.

    2. Select Oracle Rules and Oracle Rules Dictionary Component from the Extension List and click OK. This adds the Rules SDK and the Rules ADF component tag libraries to the project as shown in Figure 26-9.

    3. Click OK once more to come out of Project Properties.

    Note:

    If the 'Oracle Rules' and 'Oracle Rules Dictionary Component' do not show up in the 'Extension' List, open a SOA/BPM project within jDeveloper to load the required libraries.

  9. Click Save All to save the project.

  10. Check to make sure all the required tag libraries are added.

    1. Right click ViewController project and select Project Properties.

    2. Select JSP Tag Libraries from the menu on the left and check if all the tag libraries are added Figure 26-10.

    Figure 26-10 Checking the Required Tag Libraries

    Description of Figure 26-10 follows
    Description of "Figure 26-10 Checking the Required Tag Libraries"
26.2.2.1 How to Create the RuleSetModel Object

The Rules Editor component requires a oracle.bpel.rulesdc.model.impl.RuleSetModel object.

To create the RuleSetModel object:

  1. Create a Java Class e.g. 'SomeBean.java' in your project.
  2. Open Oracle JDeveloper.
  3. From the File menu, select New and create a Java Class.
  4. In SomeBean.java provide a method that returns the RuleSetModel object. You must specify the location/path of the rules file.The following is a sample of the SomeBean.java file:
    package view;import java.io.BufferedReader;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.Serializable;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    
    import oracle.bpel.rulesdc.model.decisiontable.impl.DecisionTablePrefsImpl;
    import oracle.bpel.rulesdc.model.decisiontable.interfaces.DecisionTablePrefs;
    import oracle.bpel.rulesdc.model.impl.IfThenPreferencesImpl;
    import oracle.bpel.rulesdc.model.impl.RuleSetModel;
    import oracle.bpel.rulesdc.model.interfaces.IfThenPreferences;
    import oracle.bpel.rulessharedutils.impl.RulesSharedUtils;
    
    import oracle.rules.sdk2.decisionpoint.DecisionPointDictionaryFinder;
    import oracle.rules.sdk2.dictionary.DictionaryFinder;
    import oracle.rules.sdk2.dictionary.RuleDictionary;
    import oracle.rules.sdk2.exception.SDKException;
    import oracle.rules.sdk2.ruleset.RuleSet;
    import oracle.rules.sdk2.ruleset.RuleSetTable;
    
    public class SomeBean {
        //on windows
        private static final String RULES_FILE1 =
     "file:///D:/scratch/asuraj/system_MAIN/rules_files/ApprovalRules.rules";
        /*
         * on linux
        private static final String RULES_FILE1 =   
     "file:////scratch/asuraj/backup/rules_files/ApprovalRules.rules";
        */
        private RuleSetModel ruleSetModel = null;
        
        private boolean viewOnly = true;
        private DecisionTablePrefs dtPrefs;
    
        private IfThenPreferences ifThenPrefs;
        
        public SomeBean() {
            super();
        }
        
        public RuleSetModel getRuleSetModel() {
            if (ruleSetModel != null)
                return ruleSetModel;
            ruleSetModel = new RuleSetModel(getRuleSet());
            System.out.println("ruleSetModel = " + ruleSetModel); 
            return ruleSetModel;
        }
        
        public RuleSet getRuleSet() {
    
            RuleDictionary dict =
                openRulesDict(RULES_FILE1, new DecisionPointDictionaryFinder());
            if (dict == null)
                return null;
    
            RuleSetTable ruleSetTable = dict.getRuleSetTable();
            if (ruleSetTable == null || ruleSetTable.isEmpty())
                return null;
    
            return ruleSetTable.get(0);
        }
        
        public void saveDictionary() {
    
            RuleDictionary dict = null;
            String rulesFile = null;
    
            if (this.ruleSetModel == null)
                return;
            dict = this.ruleSetModel.getRuleSet().getDictionary();
           
    
            if (dict == null)
                return;
    
            if (dict.isModified())
                RulesSharedUtils.updateDictionary(dict);
            if (!dict.isTransactionInProgress())
                saveDictionary(dict, RULES_FILE1);
        }
        
        public void validate() {
            if (this.ruleSetModel == null)
                return;
    
            this.ruleSetModel.validate();
        }
        
        //utility methods
        
        public static RuleDictionary openRulesDict(String fileName,
     DictionaryFinder finder) {
            URL url = null;
            try {
                url = new URL(fileName);
            } catch (MalformedURLException e) {
                System.err.println(e);
                return null;
            }
            RuleDictionary dict = null;
    
            try {
                dict = readFromDisk(url, finder);
            } catch (Exception e) {
                System.err.println(e);
                return null;
            }
            return dict;
        }
        
        public static RuleDictionary readFromDisk(URL dictURL, DictionaryFinder
     finder) {
            BufferedReader buf = null;
            try {
                buf = new BufferedReader(new
     InputStreamReader(dictURL.openStream(), "UTF-8"));
                return RuleDictionary.readDictionary(buf, finder);
            } catch (SDKException e) {
                System.err.println(e);
            } catch (IOException e) {
                System.err.println(e);
            } finally {
                if (buf != null)
                    try {
                        buf.close();
                    } catch (IOException e) {
                        System.err.println(e);
                    }
            }
    
            return null;
        }
        
        public static boolean saveDictionary(RuleDictionary dict, String
     ruleFileName) {
            if (dict == null || ruleFileName == null)
                return false;
    
            if (dict.isTransactionInProgress())
                System.out.println("Transaction in progress, cannot save
     dictionary");
    
            try {
                writeToDisk(dict, new URL(ruleFileName));
            } catch (MalformedURLException e) {
                System.err.println(e);
                return false;
            } catch (Exception e) {
                System.err.println(e);
                return false;
            }
            return true;
        }
    
        public static void writeToDisk(RuleDictionary dic, URL dictURL) {
            OutputStreamWriter writer = null;
            try {
                writer = new OutputStreamWriter(new
     FileOutputStream(dictURL.getPath()), "UTF-8");
                dic.writeDictionary(writer);
            } catch (IOException e) {
                System.err.println(e);
            } catch (SDKException e) {
                System.err.println(e);
            } finally {
                if (writer != null)
                    try {
                        writer.close();
                    } catch (IOException e) {
                        System.err.println(e);
                    }
            }
        }
    
        public void toggleMode() {
            viewOnly = !viewOnly;
        }
    
        public boolean isViewOnly() {
            return viewOnly;
        }
    
        public DecisionTablePrefs getDtPreferences() {
            if (dtPrefs == null)
                dtPrefs = new DTPreferences();
            return dtPrefs;
        }
    
        public IfThenPreferences getIfThenPreferences() {
            if (ifThenPrefs == null)
                ifThenPrefs = new MyIfThenPrefs();
            return ifThenPrefs;
        }
        public class MyIfThenPrefs extends IfThenPreferencesImpl implements
     Serializable {
    
            @Override
            public boolean isGenericAction() {
                return true;
            }
    
            @Override
            public boolean isGenericCondition() {
                return true;
            }
        }
        
        public class DTPreferences extends DecisionTablePrefsImpl implements
     Serializable {
    
            @Override
            public boolean isShowDTButtons() {
                return true;
            }
        }
    }
    
  5. Point to SomeBean.java in adfc-config.xml with Bean Name "someBean" and a "session" scope. Example adfc-config.xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <managed-bean id="__1">
        <managed-bean-name>someBean</managed-bean-name>
        <managed-bean-class>view.SomeBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </adfc-config>
    
  6. The ADF/JSF framework makes calls to SomeBean.java multiple times to render the UI. For instance, someBean.ruleSetModel is called many times. So it is more efficient to create the ruleSetModel once and cache it and return it each time instead of recreating it.
26.2.2.2 How to Create the .jspx File

The next task is to create the .jspx file to include the Rules Editor component tag.

To create the .jspx file to include the Rules Editor Component tag:

  1. Open Oracle JDeveloper.
  2. From the File menu, select New and then select JSF.
  3. Select JSF Page and click OK.
  4. Select Document Type as JSP XML.
  5. Enter rulesEditor.jspx as file name. Click OK.
  6. The RulesEditor is visible in the component window in jDeveloper.
  7. Select RulesEditor, after that the Rulesdc tag can be seen.
  8. Drag and drop the rulesdc tag into the JSPX file. You can also add the rulesDC tag manually in your jspx file like this:
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich" xmlns:rdc="http://xmlns.oracle.com/bpel/rules/editor">
        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
        <f:view>
            <af:document title="rulesEditor" id="d1">
                <af:form id="f1">
                    <af:panelGridLayout id="pgl1" inlineStyle="margin:15px;" styleClass="AFStretchWidth"
                                        partialTriggers="cb1 cb3 cb4">
                        <af:gridRow id="gr2">
                            <af:gridCell marginStart="5px" marginEnd="5px" width="100%" halign="stretch" id="gc1">
                                <af:panelGroupLayout id="pgl2" layout="horizontal">
                                    <af:commandButton text="Save Dict" action="#{someBean.saveDictionary}" id="cb1"/>
                                    <af:spacer width="10" height="10" id="s2"/>
                                    <af:commandButton text="Validate" id="cb3" action="#{someBean.validate}"
                                                      partialSubmit="true"/>
                                    <af:spacer width="10" height="10" id="s8"/>
                                    <af:commandButton text="Toggle Mode" id="cb4" action="#{someBean.toggleMode}"
                                                      partialSubmit="true"/>
                                </af:panelGroupLayout>
                            </af:gridCell>
                        </af:gridRow>
                        <af:gridRow height="100%" id="gr1">
                            <af:gridCell marginStart="5px" marginEnd="5px" width="100%" halign="stretch" valign="stretch"
                                         id="gc2">
                                <rdc:rulesdc rulesetModel="#{someBean.ruleSetModel}" id="r1"
                                             ifThenPreferences="#{someBean.ifThenPreferences}"
                                             dtPreferences="#{someBean.dtPreferences}" viewOnly="#{someBean.viewOnly}"
                                             disableVerbalRules="false"></rdc:rulesdc>
                            </af:gridCell>
                        </af:gridRow>
                    </af:panelGridLayout>
                </af:form>
            </af:document>
        </f:view>
    </jsp:root>
    
26.2.2.3 How to Refer to the Oracle Rules Shared Libraries

After creating the .jspx file, you must refer to the oracle.rules and oracle.soa.rules_dict_dc.webapp shared libraries from the weblogic-application.xml file.

To refer to the oracle.rules and the oracle.soa.rules_dict_dc.webapp shared libraries:

  1. In Oracle JDeveloper, from the Application Resources, open Descriptors, and then META-INF. Edit the weblogic-application.xml file and add the following lines (this refers to the oracle.rules shared library.)

    <library-ref>
        <library-name>oracle.rules</library-name>
    </library-ref>
    
  2. In Oracle JDeveloper,

    1. Select File menu, then select New and then Deployment Descriptors.

    2. Select Weblogic Deployment Descriptor and select weblogic.xml from the list.

    3. Select version 12.1.2 and click Finish.

    4. In weblogic.xml overview mode, select Libraries from the left and add oracle.soa.rules_dict_dc.webapp as the library name. Example weblogicogic.xml file:

      <?xml version = '1.0' encoding = 'UTF-8'?>
      <weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
      http://xmlns.oracle.com/weblogic/weblogic-web-app/1.5/weblogic-web-app.xsd"
      xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
        <library-ref>
          <library-name>oracle.soa.rules_dict_dc.webapp</library-name>
        </library-ref>
      </weblogic-web-app>
      
    5. Click Save All.

      Note:

      Note that oracle.rules and oracle.soa.rules_dict_dc.webapp shared libraries must be deployed to the embedded WLS server.

  3. All the shared libraries must be deployed using the weblogic console of your embedded WLS:

    1. Launch WLS console (http://host:port/console/login/LoginForm.jsp) and log in.

    2. Click Deployments.

      Check if oracle.rules and oracle.soa.rules_dict_dc.webapp shared libraries are deployed as shown in Figure 26-11.

  4. Deploy the shared libraries manually if they are not deployed.

    To start the WLS embedded server:

    1. Open JDeveloper.

    2. Select Run and then select Start Server Instance as shown in Figure 26-12

      Figure 26-12 Start Embedded WLS

      Description of Figure 26-12 follows
      Description of "Figure 26-12 Start Embedded WLS"

    Skip this step if the shared libraries are already deployed.

    Note:

    WLS embedded server on JDeveloper must be running so that the shared libraries can be deployed.

  5. To deploy the oracle.rules shared library to WLS:

    1. Launch WLS console (http://host:port/console/login/LoginForm.jsp) and log in.

    2. Select Deployments and click Install.

    3. Select <SOA_INSTALL>/soa/soa/modules/oracle.rules_11.1.1/rules.jar.

    4. Click Next and then click Finish.

  6. To deploy the oracle.soa.rules_dict_dc.webapp shared library to WLS:

    1. In WLS console, select Deployments, click Install.

    2. Select <SOA_INSTALL>/soa/soa/modules/oracle.soa.rules_dict_dc.webapp_11.1.1/oracle.soa.rules_dict_dc.webapp.war.

    3. Click Next and then click Finish.

    4. Select Install this deployment as a library.

    5. Click Finish.

    6. The oracle.soa.rules_dict_dc.webapp gets added to the list of deployments as shown in Figure 26-11

26.2.2.4 How to Run the Sample Application

The last task is running the sample application.

To run the Sample Application:

  1. To run the sample application, from JDeveloper, right click rulesEditor.jspx file.
  2. Select Run.

    This should start the sample application on a browser., as shown in Figure 26-13.

    Figure 26-13 Rules Editor Running

    Description of Figure 26-13 follows
    Description of "Figure 26-13 Rules Editor Running"

26.2.3 How to Deploy a Rules Editor Application to a Standalone WLS

When you are ready to deploy your application EAR file to the standalone Oracle WebLogic Server, perform the following:

  1. Check if the shared libraries are deployed using the WebLogic console of your standalone WLS.

    1. Launch WLS console. (http://host:port/console/login/LoginForm.jsp) and log in.

    2. Click Deployments. Check if oracle.rules and oracle.soa.rules_dict_dc.webapp shared libraries are deployed as showed in Figure 26-11.

  2. If the shared libraries are not deployed, then refer to the previous steps to deploy the shared libraries manually.

  3. In a project that uses the Rules Editor Component:

    1. Include Oracle Rules Dictionary Component in your Libraries and Classpath.

    This does not deploy these libraries by default, so the jars are not included in your project war file.

  4. In a project that is deploying (i.e where you create the ear file):

    1. Add this to your weblogic-application.xml:

      <library-ref>
          <library-name>oracle.rules</library-name>
      </library-ref>
      
    2. Add this to weblogic.xml in your project's war file:

      <library-ref>
          <library-name>oracle.soa.rules_dict_dc.webapp</library-name>
      </library-ref>
      
  5. Deploy your ear file in WLS.

For more information about creating an EAR file, see "How to Create an EAR File for Deployment" in Developing Fusion Web Applications with Oracle Application Development Framework.

26.2.4 What You May Need to Know About the Custom Permissions for the Rules Editor Component

For role-based authorization, Rules DC implements custom JAAS permissions (extending the oracle.adf.share.security.authorization.ADFPermission class to ensure that the permission can be used by ADF security).

If a Rules Editor application supports ADF security, which means there is support for role-based authentication and authorization, then security is enforced by implementing custom JAAS permissions (by extending the oracle.adf.share.security.authorization.ADFPermission class to ensure that the permission can be used by ADF security). You have to create ADF security policies by granting the following permissions to the user roles based on your application requirement:

  • oracle.rules.adf.permission.AddRulePermission: Displays the Add Rule button; if permission is not granted, the Add Rule button is not visible to the user.

  • oracle.rules.adf.permission.DeleteRulePermission: Displays the Delete Rule button; if permission is not granted, the Delete Rule button is not visible to the user.

  • oracle.rules.adf.permission.EditRulePermission: Displays the Edit Rule button for rules inside a ruleset; if permission is not granted, then the rules are view-only.

  • oracle.rules.adf.permission.AddDTPermission: Displays the Add Decision Table button; if permission is not granted, the Add Decision Table button is not visible to the user.

  • oracle.rules.adf.permission.DeleteDTPermission: Displays the Delete Decision Table button; if permission is not granted, the Delete Decision Table button is not visible to the user.

  • oracle.rules.adf.permission.EditDTPermission: Displays the Edit Decision Table button for decision tables within a ruleset; if permission is not granted, the decision tables are view-only.

  • oracle.rules.adf.permission.RulesEditorPermission: A global permission that sets all the preceding permissions to true.

For example, to grant the delete rule permission to a role, specify the following code in the jazn-data.xml file of the application:

<policy-store>
    <applications>
      <application>
        <name>UseRuleDictDCWtPerm</name>
        <app-roles>
          <app-role>
            <name>Admin</name>
            <class>oracle.security.jps.service.policystore.ApplicationRole</class>
            <display-name>Admin</display-name>
            <members>
              <member>
                <name>admin</name>
                <class>oracle.security.jps.internal.core.principals.JpsXmlUserImpl</class>
              </member>
            </members>
          </app-role>
          <app-role>
            <name>BusinessUser</name>
            <class>oracle.security.jps.service.policystore.ApplicationRole</class>
            <display-name>BusinessUser</display-name>
            <members>
              <member>
                <name>buser</name>
                <class>oracle.security.jps.internal.core.principals.JpsXmlUserImpl</class>
              </member>
            </members>
          </app-role>
        </app-roles>
        <jazn-policy>
          <grant>
            <grantee>
              <principals>
                <principal>
                  <class>oracle.security.jps.service.policystore.ApplicationRole</class>
                  <name>Admin</name>
                </principal>
              </principals>
            </grantee>
            <permissions>
              <permission>
                <class>oracle.rules.adf.permission.RulesEditorPermission</class>
                <name>RulesEditorPermission</name>
                <actions>access</actions>
              </permission>
            </permissions>
          </grant>
        </jazn-policy>
      </application>
    </applications>
  </policy-store>

If you do not want to use the individual permissions, such as AddRulePermission or DeleteRulePermission, you can set the RulesEditorPermission in the jazn-data.xml file to set global permissions.

26.2.5 What You May Need to Know About the Supported Tags of the Rules Editor Component

This section lists the tags and attributes that are supported by the Rules Editor component.

Table 26-1 lists the supported attributes.

Table 26-1 Supported Attributes of the Rules Editor Component

Name Type Required Default Value Supports EL? Description

rulesetModel

oracle.bpel.rulesdc
.model.interfaces.R
uleSetInterface

yes

Only EL

Wrapper around the Rules SDK ruleset object. The user can use the RuleSetModel object supplied as part of the Rules Editor Component.

ruleModel

java.lang.String

no

oracle.bpel.
rulesdc.mode
l.impl.RuleM
odel

yes

Used to customize the default RuleModel. User can extend the RuleModel class to override certain methods. Deprecated. Use 'ifThenPreferences' attribute and override getRuleModel().

simpleTestModel

java.lang.String 

no

oracle.bpel
.rulesdc.mo
del.impl.Si
mpleTestMod
el

yes

Used to customize the default SimpleTestModel. User can extend the SimpleTestModel class to override certain methods. Deprecated. Use 'ifThenPreferences' attribute and override getSimpleTestModel().

viewOnly

java.lang.Boolean

no

true

yes

In the "viewOnly" mode user can view the existing rules in the ruleset. If "false", in the "edit" mode, the user is allowed to add new rules and edit existing rules.

genericPattern

java.lang. Boolean

no

true

yes

Deprecated and not used.

genericAction

java.lang.Boolean 

no

true

yes

Deprecated and not used.

locale

java.util.Locale

no

Locale.getDe
fault()

yes

Used for Localization.

timezone

java.util.TimeZone

no

TimeZone.get
Default()

yes

Used for Localization

displayRuleSetEffDate

java.lang.Boolean

no

true

yes

Deprecated and not used.

discloseRules

java.lang.Boolean

no

false

yes

Deprecated and not used.

displayRuleSetName

java.lang.Boolean

no

false

yes

Deprecated and not used.

disableRuleSetName

java.lang.Boolean

no

false

yes

Deprecated and not used.

dtColumnPageSize

java.lang. Integer

no

5

yes

Deprecated and not used.

dtHeight

java.lang. Integer

no

16

yes

Deprecated and not used.

dateStyle

java.lang.String

no

gets it from the locale

yes

If specified, the date style is used in all inputDate components. Example: "yyyy.MM.dd"

timeStyle

java.lang.String

no

gets it from the locale

yes

If specified, the time style is used in all inutDate components.Example: "HH:mm:ss".

showValidationPanel

java.lang.Boolean

no

true

yes

Displays the validation panel by default. User can choose to hide this by setting this to false.

showDTButtons

java.lang.Boolean

no

true

yes

Deprecated and not used.

rulesPageSize

java.lang.Integer

no

5

yes

Deprecated and not used.

decimalSeparator

java.lang. Character

no

Based on Locale

yes

Used to specify the decimal separators. This is used in Number Formatting. If specified, overrides the decimal separator based on locale.

groupingSeparator

java.lang.Character

no

Based on Locale

yes

Used to specify the grouping separators. This is used in Number Formatting. If specified, overrides the grouping separator based on locale.

disableVerbalRules

java.lang.Boolean

no

true

yes

Disables verbalization UI if 'true'.

vldnPanelCollapsed

java.lang.Boolean

no

false

yes

Used to specify if validation panel should be collapsed by default.

vldnTabTitle

java.lang. String

no

-

yes

Used to specify the validation panel title.

genericDTAddActionMenu

java.lang.Boolean

yes

true

yes

If 'true', the generic add action menu is displayed in the decision table tool bar. If 'false' consumer must specify the add action menu using 'dtAddActionMenuDDC' attribute. Deprecated. Use 'dtPreferences' attribute and override isGenericDTAddActionMenu().

genericDTEditAction

java.lang.Boolean

no

true

yes

If 'true', generic action UI is displayed in the action editor browser that shows up when an action row is edited in the decision table. If 'false' consumer must specify the edit action UI using the 'dtEditActionDDC' attribute. Deprecated. Use 'dtPreferences' attribute and override isGenericDTEditAction().

genericDTActionParam

java.lang.Boolean

no

true

yes

If 'true', generic UI is displayed in the action parameter cell of the decision table. If 'false', consumer must specify the action parameter cell UI using the 'dtActionParamCellDDC' attribute. Deprecated. Use 'dtPreferences' attribute and override isGenericDTActionParam().

dtAddActionMenuDDC

jjava.lang.String

no

-

yes

Used only when 'genericDTAddActionMenu' is true. Consumer must pass the DDC (i.e the dynamic declarative component) including the context path that specifies the add menu items in the decision table toolbar. Example "/userulesdc/decisiontable/dtAddActionMenu.jsff". Deprecated. Use 'dtPreferences' attribute and override getDtAddActionMenuDDC()..

dtEditActionDDC

java.lang. String

no

-

yes

Used only when 'genericDTEditAction' is true. Consumer must pass the DDC (i.e the dynamic declarative component) including the context path that specifies the action UI to be displayed in the action editor browser that shows up when an action row is edited in the decision table. Example "/userulesdc/decisiontable/actionEditor.jsff". Deprecated. Use 'dtPreferences' attribute and override getDtEditActionDDC().

dtActionParamCellDDC

java.lang. String

no

-

yes

Used only when 'genericDTActionParam' is true. Consumer must pass the DDC (i.e the dynamic declarative component) including the context path that specifies the UI to be displayed in the action parameter cell of the decision table. Example "/userulesdc/decisiontable/actionParamCell.jsff". Deprecated. Use 'dtPreferences' attribute and override getDtActionParamCellDDC().

dtActionNameCustomizer

oracle.bpel.rulesdc
.model.interfaces.A
ctionNameCustomizer

no

-

yes

Used to specify the action name and action parameter name in the decision table header. Deprecated. Use 'dtPreferences' attribute and override getDtActionNameCustomizer().

dtPreferences

oracle.bpel.rulesdc
.model.decisiontabl
e.interfaces.Decisi
onTablePrefs 

no

oracle.bpel.
rulesdc.mode
l.decisionta
ble.impl.Dec
isionTablePr
efsImpl

yes

Used to specify decision table preferences. Consumers can extend the default implementation i.e (oracle.bpel.rulesdc.model.decisiontable.impl.DecisionTablePrefsImpl) and override only the required preferences. s.

ifThenPreferences

oracle.bpel.rulesdc
.model.interfaces.I
fThenPreferences 

no

oracle.bpel.
rulesdc.mode
l.impl.IfThe
nPreferences
Impl

yes

Used to specify if validation panel should be collapsed by default.

resourceManager

joracle.bpel.ruless
hareddc.model.inter
faces.ResourceManag
erInterface

no

-

yes

Used to specify the resource manager for translations UI. Refer to the section on 'translations'.

verbalRuleGotoDSLListener

oracle.bpel.rulessh
areddc.model.interf
aces.VerbalRuleGoto
LinkListener

no

-

yes

Listener object triggered when 'Goto phrase' link is clicked from the verbal rule.

26.3 Introduction to the Oracle Business Rules Dictionary Editor Declarative Component

Get an overview of the Oracle Business Rules Dictionary Editor declarative component.

Learn how to create and run an application using the Rules Dictionary Editor component, and then deploy the application. Also get an overview of supported tags and the localization process for the application.

26.3.1 Using the Oracle Business Rules Dictionary Component

Rules Dictionary Editor Component is an ADF Declarative Component that allows editing of Business Rules meta-data artifacts such as Rulesets, Value Sets, Globals, Decision Functions and so on using the Rules SDK2 API.

Rules Dictionary Editor Component must not be confused with the Rules Editor Component which is mainly used to edit Rules inside a specified Ruleset. The Rules Dictionary Component is a composite component that allows editing of Globals, Value sets, Rulesets and so on. The Rules Dictionary Editor Task Flow uses the Rules Dictionary Editor Component.

The Rules Dictionary Editor Component provides the following features:

  • CRUD (create/read/update/delete) operations on rulesets and general rules, verbal rules and decision tables within a ruleset.

  • CRUD (create/read/update/delete) operations on Business Phrases (used in verbalization).

  • CRUD (create/read/update/delete) operations on Value sets.

  • CRUD (create/read/update/delete) operations on Globals/Variables.

  • CRUD (create/read/update/delete) operations on Decision Functions.

  • CRUD (create/read/update/delete) operations on RL and XML Facts and viewing for all other Fact types.

  • View linked dictionaries.

  • Support for user-defined translations.

  • Cut/copy/paste of all dictionary components.

  • Compare and merge different versions of the dictionary (diff/merge support).

  • Export decision tables to Excel.

The Rules Dictionary Editor task flow uses the Rules Dictionary Editor Component to create applications. Typically, you should either use the Rules Dictionary Editor component or the Rules Dictionary Editor task flow, but not both. For more information on the Rules Dictionary Editor task flow, see Introduction to the Oracle Business Rules Dictionary Editor Task Flow.

The Rules Dictionary Editor component enables you to:

For more information about these features and tabs, see Designing Business Rules with Oracle Business Process Management.

26.3.2 How to Create and Run a Sample Application by Using the Rules Dictionary Editor Component

This section lists the steps for creating and running a sample application by using the Rules Dictionary Editor Component.

The prerequisite for using the Rules Dictionary Editor Component to create ADF-based web applications is having JDeveloper with SOA installation.The first task is to create a sample application.

To create a sample application by using the Rules Dictionary Editor Component:

  1. Open JDeveloper, from the File Menu, select New and then select ADF Fusion Web Application to create a new application as shown in Figure 26-26.

    Figure 26-26 Create Fusion Web Application.

    Description of Figure 26-26 follows
    Description of "Figure 26-26 Create Fusion Web Application."
  2. Enter a name for the application in the Application Name field, for example, UseRuleDictDCApp and click Next as shown in Figure 26-27.

    Figure 26-27 Creating a Generic Application

    Description of Figure 26-27 follows
    Description of "Figure 26-27 Creating a Generic Application"
  3. Use the default for everything else.

  4. Click Finish.

  5. Right click ViewController project and select Project Properties. Select Libraries and Classpath from the menu on the left.

    1. Click Add Library.

    2. Select Oracle Rules and Oracle Rules Dictionary Component from the Extension List and click OK. This adds the Rules SDK and the Rules ADF component tag libraries to the project as shown in Figure 26-28.

      Note:

      If the 'Oracle Rules' and 'Oracle Rules Dictionary Component' do not show up in the 'Extension' List, open a SOA/BPM project within jDeveloper to load the required libraries.

    3. Click OK once more to come out of Project Properties.

  6. Click Save All to save the project.

  7. Check to make sure all the required tag libraries are added.

    1. Right click ViewController project and select Project Properties.

    2. Select JSP Tag Libraries from the menu on the left and check if all the tag libraries are added as shown in Figure 26-29.

26.3.2.1 How to Create the RuleDictionaryModel Object

The Rules Dictionary Editor component requires a oracle.bpel.ruledictionarydc.model.impl.RuleDictionaryModel object to create the RuleDictionaryModel object.

To create the RuleDictionaryModel object:

  1. To create a Java Class e.g. SomeBean.java in your project, from the File menu, select New and then select Java Class.
  2. In SomeBean.java provide a method that returns the RuleDictionaryModel object. You must specify the location/path of the rules file. The following is an example of SomeBean.java:
    package view;
     
    import java.io.BufferedReader;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.Serializable;
     
    import java.net.MalformedURLException;
    import java.net.URL;
     
    import oracle.bpel.ruledictionarydc.model.impl.RuleDictionaryModel;
    import oracle.bpel.ruledictionarydc.model.impl.RulesEditorPreferencesImpl;
    import oracle.bpel.ruledictionarydc.model.interfaces.RulesEditorPreferences;
    import oracle.bpel.rulesdc.model.decisiontable.impl.DecisionTablePrefsImpl;
    import oracle.bpel.rulesdc.model.decisiontable.interfaces.DecisionTablePrefs;
    import oracle.bpel.rulesdc.model.impl.IfThenPreferencesImpl;
    import oracle.bpel.rulesdc.model.interfaces.IfThenPreferences;
    import oracle.bpel.rulessharedutils.impl.RulesSharedUtils;
     
    import oracle.rules.sdk2.decisionpoint.DecisionPointDictionaryFinder;
    import oracle.rules.sdk2.dictionary.DictionaryFinder;
    import oracle.rules.sdk2.dictionary.RuleDictionary;
    import oracle.rules.sdk2.exception.SDKException;
     
    public class SomeBean {
        private RuleDictionaryModel ruleDictModel;
        private RulesEditorPreferences rulesEditorPrefs;
        private boolean viewOnly = true;
     
        //on windows
        //private static final String RULES_FILE1 =
     "file:///D:/scratch/asuraj/system_MAIN/rules_
     files/insurancequoteproject/CarInsuranceRules.rules";
        
        // on linux
        private static final String RULES_FILE1 =
        "file:////scratch/asuraj/backup/rules_files/ApprovalRules.rules";
        
        public SomeBean() {
            super();
        }
     
        public RuleDictionaryModel getRuleDictModel() {
            if (ruleDictModel != null)
                return ruleDictModel;
     
        ruleDictModel = new RuleDictionaryModel(openRulesDict(RULES_FILE1, new
        DecisionPointDictionaryFinder()));
        return ruleDictModel;
        }
     
        public void saveDictionary() {
            RuleDictionary dict = null;
    
     
            if (this.ruleDictModel == null)
                return;
            dict = this.ruleDictModel.getRuleDictionary().getDictionary();
     
     
            if (dict == null)
                return;
     
            if (dict.isModified())
                RulesSharedUtils.updateDictionary(dict);
            if (!dict.isTransactionInProgress())
                saveDictionary(dict, RULES_FILE1);
        }
     
        public void validate() {
            if (this.ruleDictModel == null)
                return;
     
            this.ruleDictModel.validate();
        }
     
        public void toggleMode() {
            viewOnly = !viewOnly;
        }
     
        public boolean isViewOnly() {
            return viewOnly;
        }
     
        public RulesEditorPreferences getRulesEditorPrefs() {
            if (rulesEditorPrefs == null)
                rulesEditorPrefs = new MyRulesEditorPrefs();
            return rulesEditorPrefs;
        }
     
        //utility methods
     
        public static RuleDictionary openRulesDict(String fileName, DictionaryFinder finder) {
            URL url = null;
            try {
                url = new URL(fileName);
            } catch (MalformedURLException e) {
                System.err.println(e);
                return null;
            }
            RuleDictionary dict = null;
     
            try {
                dict = readFromDisk(url, finder);
            } catch (Exception e) {
                System.err.println(e);
                return null;
            }
            return dict;
        }
    
        public static RuleDictionary readFromDisk(URL dictURL, DictionaryFinder
     finder) {
            BufferedReader buf = null;
            try {
                buf = new BufferedReader(new
     InputStreamReader(dictURL.openStream(), "UTF-8"));
                return RuleDictionary.readDictionary(buf, finder);
            } catch (SDKException e) {
                System.err.println(e);
            } catch (IOException e) {
                System.err.println(e);
            } finally {
                if (buf != null)
                    try {
                        buf.close();
                    } catch (IOException e) {
                        System.err.println(e);
                    }
            }
            return null;    }    public static boolean saveDictionary(RuleDictionary dict, String
     ruleFileName) {
            if (dict == null || ruleFileName == null)
                return false;
    
            if (dict.isTransactionInProgress())
                System.out.println("Transaction in progress, cannot save
     dictionary");
    
            try {
                writeToDisk(dict, new URL(ruleFileName));
            } catch (MalformedURLException e) {
                System.err.println(e);
                return false;
            } catch (Exception e) {
                System.err.println(e);
                return false;
            }
            return true;
        }
    
        public static void writeToDisk(RuleDictionary dic, URL dictURL) {
            OutputStreamWriter writer = null;
            try {
                writer = new OutputStreamWriter(new
     FileOutputStream(dictURL.getPath()), "UTF-8");
                dic.writeDictionary(writer);
            } catch (IOException e) {
                System.err.println(e);
            } catch (SDKException e) {
                System.err.println(e);
            } finally {
                if (writer != null)
                    try {
                        writer.close();
                    } catch (IOException e) {
                        System.err.println(e);
                    }
            }
        }
    
        public class MyRulesEditorPrefs extends RulesEditorPreferencesImpl
     implements Serializable {
    
            private DecisionTablePrefs dtPrefs;
            private IfThenPreferences ifThenPrefs;
    
            @Override
            public DecisionTablePrefs getDecisionTablePreferences() {
                if (dtPrefs == null)
                    dtPrefs = new DTPreferences();
                return dtPrefs;
            }
    
            @Override
            public IfThenPreferences getIfThenPreferences() {
                if (ifThenPrefs == null)
                    ifThenPrefs = new MyIfThenPrefs();
                return ifThenPrefs;
            }
    
            @Override
            public boolean isShowRSButtons() {
                return true;
            }
        }
    
        public class MyIfThenPrefs extends IfThenPreferencesImpl implements
     Serializable {
    
            @Override
            public boolean isGenericAction() {
                return true;
            }
    
            @Override
            public boolean isGenericCondition() {
                return true;
            }
        }    public class DTPreferences extends DecisionTablePrefsImpl implements
     Serializable {
    
            @Override
            public boolean isShowDTButtons() {
                return true;
            }
        }
    }
    
  3. Point to SomeBean.java in adfc-config.xml with Bean Name someBean and a session scope. Example adfc-config.xml.
  4. Ensure that Java Class under Items is selected and click OK to display the Create Java Class dialog box.
    <?xml version="1.0" encoding="UTF-8" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <managed-bean id="__1">
        <managed-bean-name>someBean</managed-bean-name>
        <managed-bean-class>view.SomeBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </adfc-config>
    
  5. The ADF/JSF framework makes calls to SomeBean.java multiple times to render the UI. For instance, someBean.ruleDictModel is called many times. So it is more efficient to create the ruleDictModel once and cache it and return it each time instead of recreating it.
26.3.2.2 How to Create .jspx File for the Rules Dictionary Editor Component

The next task is to create the .jspx file to include the Rules Dictionary Editor Component tag.

To create the .jspx file for the Rules Dictionary Editor Component tag:

  1. Open Oracle JDeveloper.
  2. From the File Menu, select New and then select JSF/Facelets.
  3. Select JSF Page and click OK.
  4. Select Document Type as JSP XML.
  5. Enter file name as ruleDictEditor.jspx. Click OK.
  6. The RuleDictionaryDC is visible in the Components window in jDeveloper as shown in Figure 26-30.
  7. Select RuleDictionaryDC, now you should see the RuleDictionaryDC tag. Drag and drop the RuleDictionaryDC tag into the JSPX fileFigure 26-31.

    Figure 26-31 Rule Dictionary DC Tag

    Description of Figure 26-31 follows
    Description of "Figure 26-31 Rule Dictionary DC Tag"

    You can also add the 'RuleDictionaryDC' tag manually in your jspx file like this:

    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:rddc="http://xmlns.oracle.com/bpel/rules/dictionaryEditor">
        <jsp:directive.page contentType="text/html;charset=UTF-8"/>
        <f:view>
            <af:document title="ruleDictEditor" id="d1">
                <af:form id="f1">
                    <af:panelGridLayout id="pgl1" inlineStyle="margin:15px;" styleClass="AFStretchWidth"
                                        partialTriggers="cb2 cb3 cb6">
                        <af:gridRow id="dc_gr1" marginTop="5px" marginBottom="5px">
                            <af:gridCell marginStart="5px" marginEnd="5px" width="100%" halign="stretch" id="gc1">
                                <af:panelGroupLayout id="pgl3" layout="horizontal">
                                    <af:button text="Save Dictionary" id="cb2" action="#{someBean.saveDictionary}"/>
                                    <af:spacer width="10" height="10" id="s1"/>
                                    <af:button text="Validate" id="cb3" action="#{someBean.validate}"/>
                                    <af:spacer width="10" height="10" id="s3"/>
                                    <af:button text="Toggle Mode" id="cb6" action="#{someBean.toggleMode}"/>
                                </af:panelGroupLayout>
                            </af:gridCell>
                        </af:gridRow>
                        <af:gridRow height="100%" id="gr2">
                            <af:gridCell width="100%" halign="stretch" valign="stretch" id="gc2">
                                <!-- Content -->
                                <rddc:ruleDictionaryDC ruleDictModel="#{someBean.ruleDictModel}" id="rddc1"
                                                       rulesEditorPrefs="#{someBean.rulesEditorPrefs}"
                                                       viewOnly="#{someBean.viewOnly}" disableVerbalRules="false"/>
                            </af:gridCell>
                        </af:gridRow>
                    </af:panelGridLayout>
                </af:form>
            </af:document>
        </f:view>
    </jsp:root>
    
26.3.2.3 How to Refer the oracle.rules and the oracle.soa.rules_dict_dc.webapp Shared Libraries

After creating the .jspx file, you must refer to the oracle.rules and oracle.soa.rules_dict_dc.webapp shared libraries from the weblogic-application.xml file.

To refer to the oracle.rules and the oracle.soa.rules_dict_dc.webapp shared libraries:

  1. In JDeveloper from Application Resources select Descriptors and then META-INF. Edit the weblogic-application.xml file and add the following lines (this refers to the oracle.rules shared library):

    <library-ref>
        <library-name>oracle.rules</library-name>
    </library-ref>
    
  2. In JDeveloper select File, then New and then Deployment Descriptors.

    1. Select Weblogic Deployment Descriptor and then select weblogic.xml from the list.

    2. Select version 12.1.2 and click Finish.

    3. In weblogic.xml overview mode, select Libraries from the left and add library name as oracle.soa.rules_dict_dc.webapp. Example weblogic.xml file:

      <?xml version = '1.0' encoding = 'UTF-8'?>
      <weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
      http://xmlns.oracle.com/weblogic/weblogic-web-app/1.5/weblogic-web-app.xsd"
      xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
        <library-ref>
          <library-name>oracle.soa.rules_dict_dc.webapp</library-name>
        </library-ref>
      </weblogic-web-app>
      
    4. Click Save All.

    Note:

    Note that 'oracle.rules' and 'oracle.soa.rules_dict_dc.webapp' shared libraries must be deployed to the embedded WLS server.

  3. Check to make sure the shared libraries are deployed using the weblogic console of your embedded WLS.

    1. Launch WLS console (http://host:port/console/login/LoginForm.jsp) and log in.

    2. Click Deployments and see if oracle.rules and oracle.soa.rules_dict_dc.webapp shared libraries are deployed as shown in Figure 26-32.

  4. If the shared libraries are not deployed, then follow this process to deploy them manually:

    1. To start the WLS embedded server, in JDeveloper select Run and then select Start Server Instance as shown in Figure 26-33.

      Figure 26-33 Start Server Instance

      Description of Figure 26-33 follows
      Description of "Figure 26-33 Start Server Instance"

      Skip this if the shared libraries are already deployed.

      Note:

      WLS embedded server on JDeveloper must be running so that the shared libraries can be deployed.

  5. To deploy the oracle.rules shared library to WLS:

    1. Launch WLS console (http://host:port/console/login/LoginForm.jsp) and log in.

    2. Select Deployments and click Install.

    3. Select <SOA_INSTALL>/soa/soa/modules/oracle.rules_11.1.1/rules.jar and then click Next and Finish.

  6. To deploy the oracle.soa.rules_dict_dc.webapp shared library to WLS:

    1. In WLS console, select Deployments, click Install.

    2. Select <SOA_INSTALL>/soa/soa/modules/oracle.soa.rules_dict_dc.webapp_11.1.1/oracle.soa.rules_dict_dc.webapp.war.

    3. Click Next and then click Finish.

    4. Select Install this deployment as a library.

    5. Click Finish

    6. Now you should see oracle.soa.rules_dict_dc.webapp added to the list of deployments. as shown in Figure 26-32.

26.3.2.4 How to Run the Sample Rules Dictionary Editor Application

The last task is running the sample application.

To run the sample Rules Dictionary Editor application:

  1. To run the sample application, from JDeveloper, right click ruleDictEditor.jspx file.
  2. Select Run.

    This should start the sample application on a browser as shown in Figure 26-34.

Figure 26-34 Rules Dictionary Editor Application

Description of Figure 26-34 follows
Description of "Figure 26-34 Rules Dictionary Editor Application"

26.3.3 How to Deploy a Rules Dictionary Application to a Standalone Oracle WebLogic Server

When you're ready to deploy your application ear file to the stand-alone WLS, follow these steps to make sure everything runs smoothly.

  1. Check to make sure the shared libraries are deployed using the weblogic console of your stand-alone WLS.

    1. Launch WLS console http://host:port/console/login/LoginForm.jsp and log in.

    2. Click 'Deployments' and see if 'oracle.rules' and 'oracle.soa.rules_dict_dc.webapp' shared libraries are deployed as shown in Figure 26-11.

  2. If the shared libraries are not deployed, then follow the previous process to deploy the shared libraries manually.

  3. In your project that uses the Rule Dictionary Editor Component, include the "Oracle Rules Dictionary Component" in your 'Libraries and Classpath'. This does not deploy these libraries by default, so the jars are not included in your project war file.

  4. In the project that is finally deploying (i.e where you create the ear file):

    1. Add this to your weblogic-application.xml:

      <library-ref>
          <library-name>oracle.rules</library-name>
      </library-ref>
      
    2. Add this to weblogic.xml in your project's war file:

      <library-ref>
          <library-name>oracle.soa.rules_dict_dc.webapp</library-name>
      </library-ref>
      
  5. Now you can deploy your ear file in WLS and things should work.

26.3.4 What You May Need to Know About the Supported Attributes of the Rules Dictionary Editor Component

This section lists the attributes that are supported by the Rules Dictionary Editor component.

Table 26-2 lists the supported attributes.

Table 26-2 Supported Rules Dictionary Editor Attributes

Name Type Required Default Value Supports EL? Description

ruleDictModel

oracle.bpel.ruledict
ionarydc.model.inter
faces.RuleDictionary
Interface

yes

-

Only EL

Wrapper around the Rules SDK Dictionary object.The user can use the RuleDictionaryModel object supplied as part of the Rules Dictionary Editor Component jar file (adflibRuleDictionaryDC.jar).

viewOnly

java.lang.Boolean

no

true

yes

In the "viewOnly" mode user can view the existing dictionary data but cannot edit. If "false", i.e. the "edit" mode, the user is allowed to edit the dictionary.

locale

java.util.Locale

no

Locale.getD
efault()

yes

Used for Localization.

timezone

java.util.TimeZone

no

TimeZone.ge
tDefault() 

yes

Used for Localization

ruleModel

java.lang.String

no

oracle.bpel
.rulesdc.mo
del.impl.Ru
leModel

yes

Used to customize the default RuleModel. User can extend the RuleModel class to override certain methods. Deprecated. Use 'rulesEditorPrefs' and override getIfThenPreferences().getRuleModel().

simpleTestModel

java.lang.String

no

oracle.bpel
.rulesdc.mo
del.impl.Si
mpleTestMod
el 

yes

Used to customize the default SimpleTestModel. User can extend the SimpleTestModel class to override certain methods. Use 'rulesEditorPrefs' and override getIfThenPreferences().getSimpleTestModel().

selectedTab

java.lang.String

no

-

yes

Switches to the specified tab name (either GLOBALS, FACTS, VALUESETS, LINKS, DESC_FUNCS, DSL_DEFNS, TESTS, TRANSLATIONS or the ruleset name).

selectedRulesetIdx

java.lang.String

no

-

yes

Used to specify the ruleset index to be selected by default. If 'selectedRulesetIdx' is specified, it overrides the 'selectedTab' attribute.

dtColumnPageSize

java.lang.Integer

no

5

yes

Deprecated and not used.

dtHeight

java.lang.Integer

no

16

yes

Deprecated and not used.

dateStyle

java.lang.String

no

gets it from the locale

yes

If specified, the date style is used in all inputDate components. Example: "yyyy.MM.dd".

timeStyle

java.lang.String

no

gets it from the locale

yes

If specified, the time style is used in all inutDate components.Example: "HH:mm:ss".

showValidationPanel

java.lang.Boolean

no

true

yes

Displays the validation panel by default. User can choose to hide this by setting this to false.

discloseRules

java.lang.Boolean

no

false

yes

Deprecated and not used.

displayRuleSetName

java.lang.Boolean

no

true

yes

Deprecated and not used.

disableRuleSetName

java.lang.Boolean

no

false

yes

Deprecated and not used.

showDTButtons

java.lang.Boolean

no

true

yes

Deprecated and not used

disableDFName

java.lang.Boolean

no

false

yes

Disables the Decision Function Name in the Decision Function editor pop-up if true. Deprecated. Use 'dfEditorPrefs' and override isDisableDFName().

displayWSName

java.lang.Boolean

no

true

yes

Displays the decision service name if 'true' in the Decision Function editor pop-up. Note that the service name makes sense only when 'Invoke as rule service' is checked. Deprecated. Use 'dfEditorPrefs' and override isDisplayWSName()..

displayWSCheck

java.lang.Boolean

no

true

yes

Displays the 'Invoke as rule service' check box in the Decision Function editor pop-up if true. Deprecated. Use 'dfEditorPrefs' and override isDisplayWSCheck().

disableInputOps

java.lang.Boolean

no

false

yes

Disables add, edit and delete operations for the Inputs table in the Decision Function editor pop-up. Deprecated. Use 'dfEditorPrefs' and override isDisableInputOps().

disableOutputOps

java.lang.Boolean

no

false

yes

Disables add, edit and delete operations for the Outputs table in the Decision Function editor pop-up. Deprecated. Use 'dfEditorPrefs' and override isDisableOutputOps().

displayAddDF

java.lang.Boolean

no

true

yes

Displays the add decision function button. Deprecated. Use 'dfEditorPrefs' and override isDisableAddDF().

displayDeleteDF

java.lang.Boolean

no

true

yes

Displays the delete decision function button. Deprecated. Use 'dfEditorPrefs' and override isDisableDeleteDF().

rulesPageSize

java.lang.Integer

no

5

yes

Deprecated and not used.

decimalSeparator

java.lang.Character

no

Based on Locale

yes

Used to specify the decimal separators. This is used in Number Formatting. If specified, overrides the decimal separator based on locale.

groupingSeparator

java.lang.Character

no

Based on Locale

yes

Used to specify the grouping separators. This is used in Number Formatting. If specified, overrides the grouping separator based on locale.

vldnPanelCollapsed

java.lang.Boolean

no

false

yes

Used to specify if validation panel should be collapsed by default.

vldnTabTitle

java.lang.String

no

Localized text "Business Rule Validation - Log"

yes

Used to specify the validation panel title.

resourceManager

oracle.bpel.rulessha
reddc.model.interfac
es.ResourceManagerIn
terface

no

-

yes

Used to specify the resource manager for translations UI. Refer to the section on 'translations'.

rulesEditorPrefs

oracle.bpel.ruledict
ionarydc.model.inter
faces.RulesEditorPre
ferences  

no

oracle.bpel
.ruledictio
narydc.mode
l.impl.Rule
sEditorPref
erencesImpl

yes

Used to specify the rules editor preferences. Consumers can extend the default implementation i.e (oracle.bpel.ruledictionarydc.model.impl.RulesEditorPreferencesImpl) and override only the required preferences.

dfEditorPrefs

oracle.bpel.ruledict
ionarydc.model.inter
faces.DFEditorPrefer
ences 

no

oracle.bpel
.ruledictio
narydc.mode
l.impl.DFEd
itorPrefere
ncesImpl 

yes

Used to specify the decision function editor preferences. Consumers can extend the default implementation i.e (oracle.bpel.ruledictionarydc.model.impl.DFEditorPreferencesImpl) and override only the required preferences.

showRSButtons

java.lang.Boolean

no

true

yes

Deprecated and not used.

dfListener

oracle.bpel.decision
funceditordc.listene
r.DecisionFuncListen
er

no

-

yes

Used for notification of decision function editor updates. Deprecated. Use 'dfEditorPrefs' and override getDfListener().

dfActionListener

oracle.bpel.ruledict
ionarydc.listener.De
cisionFuncActionList
ener 

no

-

yes

Used for notification when a decision function is added or deleted. Deprecated. Use 'dfEditorPrefs' and override getDfActionListener()

dfServiceNameCustomize

oracle.bpel.decision
funceditordc.listene
r.DecisionFuncServic
eNameCustomizer

no

-

yes

Used to customize the decision function service name. Deprecated. Use 'dfEditorPrefs' and override getDfServiceNameCustomizer().

dictVersionInfo

oracle.bpel.ruledict
ionarydc.model.inter
faces.DictVersionInf
o 

no

-

yes

Used in diff/merge to retrieve the list of dictionary versions for comparison. Deprecated. Use 'dfEditorPrefs' and override getDfServiceNameCustomizer().

testExecutor

oracle.bpel.testedit
ordc.interfaces.Test
Executor

no

-

yes

Used for executing test suites, test templates and test cases.

disableRulesTesting

java.lang.Boolean

no

false

yes

If true, the rule testing capability is disabled.

disableVerbalRules

java.lang.Boolean

no

true

yes

If true, the verbalization capability is disabled that is the Business Phrases tab is not displayed and CRUD operations on verbal rules are disabled.

boUpdateListener

oracle.bpel.ruledict
ionarydc.listener.BO
UpdateListener 

no

-

yes

Used for synchronizing business objects.

26.4 Introduction to the Oracle Business Rules Dictionary Editor Task Flow

Get an overview of the Oracle Business Rules Dictionary Editor task flow.

Learn how to create and run an application using the Rules Dictionary Editor task flow, and then deploy the application.

26.4.1 Using the Oracle Business Rules Dictionary Task Flow

The Oracle Rules Dictionary Editor Task Flow is basically a wrapper around the Rules Dictionary Editor declarative component. The task flow is used in ADF-based web applications that require a task flow instead of a declarative component. For more information on the Rules Dictionary Editor component, see Introduction to the Oracle Business Rules Dictionary Editor Declarative Component.

26.4.2 How to Create and Run a Sample Application By Using the Rules Dictionary Editor Task Flow

This section lists the steps for creating and running a sample application by using the Oracle Rules Dictionary Editor task flow.

The prerequisites for using the Oracle Rules Dictionary Editor task flow to create ADF-based web applications is having a running installation of Oracle SOA Suite and Oracle JDeveloper on your computer.

The first task is to create a sample application.

To create a sample application by using the Oracle Rules Dictionary Editor task flow:

  1. Open Oracle JDeveloper.

  2. From the File menu, select New and then Custom Application to create an application.

  3. Enter a name for the application in the Application Name field, for example, useRuleDictTaskFlowApp, and click Next as shown in Figure 26-35.

    Figure 26-35 Creating a Generic Task Flow Application

    Description of Figure 26-35 follows
    Description of "Figure 26-35 Creating a Generic Task Flow Application"
  4. Enter useRuleDictTaskFlow in the Project Name field and ensure that ADF Faces is selected in the Project Technologies tab, as shown in Figure 26-36.

    Figure 26-36 Creating a Task Flow Project

    Description of Figure 26-36 follows
    Description of "Figure 26-36 Creating a Task Flow Project"
  5. Click Finish to create the project.

  6. Right-click the useRuleDictTaskFlow project in the Applications window of Oracle JDeveloper, and select Project Properties to display the Project Properties dialog box.

    In the Project Properties dialog box:

    1. Select JSP Tag Libraries from the left panel.

    2. Click Add and select ADF Faces Components from the Extension list in the Choose Tag Libraries dialog box, and click OK as shown in Figure 26-37.

      Figure 26-37 Choosing Tab Libraries for the Task Flow Application

      Description of Figure 26-37 follows
      Description of "Figure 26-37 Choosing Tab Libraries for the Task Flow Application"
    3. Select Libraries and Classpath from the left panel and click Add Library to display the Add Library dialog box.

    4. Select Oracle Rules and then Oracle Rules Dictionary Task Flow in the Libraries list and click OK as shown in Figure 26-38. This adds the Rules SDK and the Rules Dictionary Task Flow JARs to the project.

      Figure 26-38 Adding the Rules SDK and Rules Dictionary Task Flow

      Description of Figure 26-38 follows
      Description of "Figure 26-38 Adding the Rules SDK and Rules Dictionary Task Flow"
    5. Click OK to close the Project Properties dialog box.

  7. Click Save All from the Oracle JDeveloper File menu to save the project.

  8. Create a Java class that implements the oracle.integration.console.metadata.model.share.MetadataDetails interface, which is defined in soaComposerTemplates.jar. For more information on the MetadataDetails interface, see The MetadataDetails Interface.

    The steps are:

    1. Open Oracle JDeveloper.

    2. From the File menu, select New to display the New Gallery dialog box.

    3. In the New Gallery dialog box, select Java under General from the Categories panel. Ensure that Java Class under Items is selected and click OK to display the Create Java Class dialog box.

    4. Enter the name of the Java class, for example MyMetaDataDetails.

    5. Add the MetadataDetails interface in the Implements box under Optional Attributes, and click OK to create the Java class in your project, as shown in Figure 26-39.

      Figure 26-39 Creating a Java Class that Implements the MetadataDetails Interface

      Description of Figure 26-39 follows
      Description of "Figure 26-39 Creating a Java Class that Implements the MetadataDetails Interface"

      The following is a sample of the content of the MyMetaDataDetails.java file:

      package useruledicttaskflow;
      
      import java.io.BufferedReader;
      import java.io.FileNotFoundException;
      import java.io.FileOutputStream;
      import java.io.IOException;
      import java.io.InputStream;
      import java.io.InputStreamReader;
      import java.io.OutputStreamWriter;
      import java.io.UnsupportedEncodingException;
      import java.io.Writer;
      
      import java.net.MalformedURLException;
      import java.net.URL;
      
      import oracle.integration.console.metadata.model.share.MetadataDetails;
      import oracle.integration.console.metadata.model.share.RelatedMetadataPath;
      
      public class MyMetaDataDetails implements MetadataDetails {
          public MyMetaDataDetails() {
              super();
          }
      
          private static final String RULES_FILE1 =
              "file:///<path of Rules file>";
      
          public String getDocument() {
              URL url = null;
              try {
                  url = new URL(RULES_FILE1);
                  return readFile(url);
              } catch (IOException e) {
                  System.err.println(e);
              }
              return "";
          }
      
          public void setDocument(String string) {
              URL url = null;
      
              try {
                  url = new URL(RULES_FILE1);
              } catch (MalformedURLException e) {
                  System.err.println(e);
                  return;
              }
              Writer writer = null;
              try {
                  //os = new FileWriter(url.getPath());
                  writer =
                     new OutputStreamWriter(new FileOutputStream(url.getPath()),
                    "UTF-8");
             } catch (FileNotFoundException e) {
                  System.err.println(e);
                  return;
              } catch (IOException e) {
                  System.err.println(e);
                  return;
              }
              try {
                  writer.write(string);
              } catch (IOException e) {
                  System.err.println(e);
              } finally {
                  if (writer != null) {
                      try {
                          writer.close();
                      } catch (IOException ioe) {
                          System.err.println(ioe);
                      }
                  }
              }
          }
      
          private String readFile(URL dictURL) {
              InputStream is;
              try {
                  is = dictURL.openStream();
              } catch (IOException e) {
                  System.err.println(e);
                  return "";
              }
              BufferedReader reader;
              try {
                 reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
              } catch (UnsupportedEncodingException e) {
                  System.err.println(e);
                  return "";
              }
              String line = null;
              StringBuilder stringBuilder = new StringBuilder();
              String ls = System.getProperty("line.separator");
              try {
                  while ((line = reader.readLine()) != null) {
                      stringBuilder.append(line);
                      stringBuilder.append(ls);
                  }
              } catch (IOException e) {
                  System.err.println(e);
                  return "";
              } finally {
                  try {
                      reader.close();
                  } catch (IOException e) {
                      System.err.println(e);
                  }
              }
              return stringBuilder.toString();
          }
      
      public String getRelatedDocument(RelatedMetadataPath relatedMetadataPath) {
              String currPath =
                  RULES_FILE1.substring(0, RULES_FILE1.indexOf("oracle/rules"));
              String relatedDoc =
                  currPath + "oracle/rules/" + relatedMetadataPath.getValue();
      
              URL url = null;
              try {
                  url = new URL(relatedDoc);
                  return readFile(url);
              } catch (IOException e) {
                  System.err.println(e);
              }
              return "";
          }
      }
      
  9. Create a Java class called MyNLSPreferences that implements the oracle.integration.console.metadata.model.share.NLSPreferences interface, which is defined in soaComposerTemplates.jar.

    For more information about the NLS Preferences interface, see The NLSPreferences Interface.

    The following sample of MyNLSPreferences.java implements the NLSPreferences interface:

    package useruledicttaskflow;
    
    import java.util.Locale;
    import java.util.TimeZone;
    
    import oracle.integration.console.metadata.model.share.NLSPreferences;
    
    public class MyNLSPreferences implements NLSPreferences {
        private static final String DATE_STYLE = "yyyy-MM-dd";
        private static final String TIME_STYLE = "HH-mm-ss";
        
        public MyNLSPreferences() {
            super();
        }
    
        public Locale getLocale() {
            return Locale.getDefault();
        }
    
        public TimeZone getTimeZone() {
            return TimeZone.getTimeZone("America/Los_Angeles");
        }
    
        public String getDateFormat() {
            return DATE_STYLE;
        }
    
        public String getTimeFormat() {
            return TIME_STYLE;
        }
    }
    
  10. Create a managed bean called MyBean.java to return the implementation of MetadataDetails and NLSPreferences. It also returns the oracle.integration.console.metadata.model.share.MetadataDetailsMode object and provides event handlers such as toggleMode(), saveDictionary(), saveNoValidateDictionary(), and validate().

    The following is a sample of the MyBean.java file:

    package useruledicttaskflow;
    
    import javax.el.ELContext;
    import javax.el.ExpressionFactory;
    import javax.el.MethodExpression;
    
    import javax.faces.context.FacesContext;
    import javax.faces.event.PhaseId;
    
    import oracle.adf.view.rich.component.rich.fragment.RichRegion;
    
    import oracle.integration.console.metadata.model.share.MetadataDetails;
    import oracle.integration.console.metadata.model.share.MetadataDetailsMode;
    import oracle.integration.console.metadata.model.share.NLSPreferences;
    
    public class MyBean {
        private MyMetaDataDetails details = null;
        private MetadataDetailsMode mode = MetadataDetailsMode.VIEW;
        private RichRegion regionComp;
        private NLSPreferences nlsPrefs;
    
        public MyBean() {
            super();
        }
    
        public MetadataDetails getMetaDataDetails() {
            if (details != null)
                return details;
    
            details = new MyMetaDataDetails();
            return details;
        }
    
        public MetadataDetailsMode getDetailsMode() {
            return mode;
        }
    
        public void toggleMode() {
            if (mode.equals(MetadataDetailsMode.EDIT))
                mode = MetadataDetailsMode.VIEW;
            else
                mode = MetadataDetailsMode.EDIT;
        }
    
        public void saveDictionary() {
            if (regionComp == null)
                return;
            FacesContext fc = FacesContext.getCurrentInstance();
            ExpressionFactory ef = fc.getApplication().getExpressionFactory();
            ELContext elc = fc.getELContext();
            MethodExpression me =
                ef.createMethodExpression(elc, "doMetadataUpdate", String.class,
                                          new Class[] { });
            regionComp.queueActionEventInRegion(me, null, null, false, -1, -1,
                                                PhaseId.ANY_PHASE);
        }
    
        public void saveNoValidateDictionary() {
            if (regionComp == null)
                return;
            FacesContext fc = FacesContext.getCurrentInstance();
            ExpressionFactory ef = fc.getApplication().getExpressionFactory();
            ELContext elc = fc.getELContext();
            MethodExpression me =
                ef.createMethodExpression(elc, "doNoValidateMetadataUpdate",
                                          String.class, new Class[] { });
            regionComp.queueActionEventInRegion(me, null, null, false, -1, -1,
                                                PhaseId.ANY_PHASE);
        }
    
        public void validate() {
            if (regionComp == null)
                return;
            FacesContext fc = FacesContext.getCurrentInstance();
            ExpressionFactory ef = fc.getApplication().getExpressionFactory();
            ELContext elc = fc.getELContext();
            MethodExpression me =
                ef.createMethodExpression(elc, "doValidate", String.class,
                                          new Class[] { });
            regionComp.queueActionEventInRegion(me, null, null, false, -1, -1,
                                                PhaseId.ANY_PHASE);
        }
    
        public void setRegionComp(RichRegion regionComp) {
            this.regionComp = regionComp;
        }
        public RichRegion getRegionComp() {
            return regionComp;
        }
    
        public NLSPreferences getNlsPrefs() {
            if (nlsPrefs != null)
                return nlsPrefs;
    
            nlsPrefs = new MyNLSPreferences();
            return nlsPrefs;
        }
    }
    
  11. Open the faces-config.xml file in Overview mode and click the + button under Managed Beans to display the Create Managed Bean dialog box.

  12. Point to MyBean.java by entering MyBean in the Bean Name field and selecting session from the Scope list, as shown in Figure 26-40.

    Figure 26-40 Specifying the Bean Name and Scope in the Task Flow Application

    Description of Figure 26-40 follows
    Description of "Figure 26-40 Specifying the Bean Name and Scope in the Task Flow Application"
26.4.2.1 How to Add a Rule Dictionary Editor Task Flow

The next task is to create the .jspx file to include the Rules Dictionary Editor component tag.

To add a Rules Dictionary Editor task flow in a .jspx file:

  1. Open Oracle JDeveloper.
  2. From the File menu, select New to display the New Gallery dialog box.
  3. In the New Gallery dialog box, select JSF under Web Tier from the Categories panel.
  4. Select JSF Page under Items and click OK to display the Create JSF Page dialog box, as shown in Figure 26-41.

    Figure 26-41 Creating the JSF Page File to Include the Rules Dictionary Editor Task Flow

    Description of Figure 26-41 follows
    Description of "Figure 26-41 Creating the JSF Page File to Include the Rules Dictionary Editor Task Flow"
  5. In the Create JSF Page dialog box, enter useRuleDictTaskFlow.jspx as the file name, as shown in Figure 26-42.

    Figure 26-42 Specifying the Name of the JSF Page for the Task Flow

    Description of Figure 26-42 follows
    Description of "Figure 26-42 Specifying the Name of the JSF Page for the Task Flow"

    adflibRuleDictionaryTaskFlow.jar is displayed in the Components window of Oracle JDeveloper, as shown in Figure 26-43.

    Figure 26-43 Rules Dictionary Task Flow JAR in the Components Window

    Description of Figure 26-43 follows
    Description of "Figure 26-43 Rules Dictionary Task Flow JAR in the Components Window"

    This is because you have added the Oracle Rules Dictionary Task Flow shared library when creating the sample application.

  6. Select adflibRuleDictionaryTaskFlow.jar to make rule-dict-flow-definition available under Regions in the Components window. You can drag and drop the rule-dict-flow-definition region into the .jspx file as shown in Figure 26-44, and specify all the required parameters.

    Figure 26-44 Dragging and Dropping the Region

    Description of Figure 26-44 follows
    Description of "Figure 26-44 Dragging and Dropping the Region"

    The following is a sample of the useRuleDictTaskFlow.jspx file with the task flow added:

    <f:view>
        <af:document id="d1">
          <af:form id="f1">
            <af:panelStretchLayout id="psl1" inlineStyle="margin:8px;">
              <f:facet name="top">
                <af:menuBar id="mb1">
                  <af:commandMenuItem text="Toggle Mode" id="cmi1"
                                      action="#{MyBean.toggleMode}"
                                      partialSubmit="true"/>
                  <af:commandMenuItem text="Save Dict" id="cmi2"
                                      action="#{MyBean.saveDictionary}"
                                      partialSubmit="true"/>
                  <af:commandMenuItem text="Save Dict No Validate" id="cmi3"
                                      action="#{MyBean.saveNoValidateDictionary}"
                                      partialSubmit="true"/>
                  <af:commandMenuItem text="Validate" id="cmi4"
                                      action="#{MyBean.validate}"
                                      partialSubmit="true"/>
                </af:menuBar>
              </f:facet>
              <f:facet name="center">
                <af:region value="#{bindings.rulesdictflowdefinition1.regionModel}"
                             id="r2" binding="#{MyBean.regionComp}"
                             partialTriggers="::cmi1 ::cmi2 ::cmi3 ::cmi4"/>
              </f:facet>
            </af:panelStretchLayout>
          </af:form>
        </af:document>
      </f:view>
    

    In the preceding sample, you can find code snippets for rendering the following buttons to the page:

    • Toggle Mode: Enables switching between read-only and editable modes of Oracle SOA Composer.

    • Save Dict: Enables saving the dictionary (with or without validation).

26.4.2.2 How to Edit the pagedef.xml File

After you add the task flow to the .jspx file, you must edit the useRuleDictTaskFlowPageDef.xml file. The pagedef.xml file is created when you drop the Rules Dictionary task flow into the .jspx page.

The following is a sample of the pagedef.xml file along with all the parameters that must be passed to the rules dictionary task flow:

<?xml version="1.0" encoding="UTF-8" ?>
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel"
                version="11.1.1.55.99" id="useRuleDictTaskFlowPageDef"
                Package="useruledicttaskflow.pageDefs">
 <parameters/>
  <executables>
    <variableIterator id="variables"/>
    <taskFlow id="rulesdictflowdefinition1"
   taskFlowId= "/WEB-INF/rule-dict-flow-definition.xml#rules-dict-flow-definition"
   activation="deferred"
   xmlns="http://xmlns.oracle.com/adf/controller/binding">
 <parameters>
        <parameter id="details" value="#{MyBean.metaDataDetails}"
                   xmlns="http://xmlns.oracle.com/adfm/uimodel"/>
        <parameter id="mode" value="#{MyBean.detailsMode}"
                   xmlns="http://xmlns.oracle.com/adfm/uimodel"/>
        <parameter id="dtHeight" value="10"
                   xmlns="http://xmlns.oracle.com/adfm/uimodel"/>
        <parameter id="selectedTab" value="Ruleset_1"
                   xmlns="http://xmlns.oracle.com/adfm/uimodel"/>
        <parameter id="dtColumnPageSize" value="6"
                   xmlns="http://xmlns.oracle.com/adfm/uimodel"/>
        <parameter id="nlsPrefs" value="#{MyBean.nlsPrefs}"
                   xmlns="http://xmlns.oracle.com/adfm/uimodel"/>
        <parameter id="discloseRules" value="true"
                   xmlns="http://xmlns.oracle.com/adfm/uimodel"/>
      </parameters>
    </taskFlow>
  </executables>
  <bindings/>
</pageDefinition
26.4.2.3 How to Refer to oracle.rules and oracle.soa.rules_dict_dc.webapp Shared Libraries

The next task is to refer to the oracle.rules and oracle.soa.rules_dict_dc.webapp shared libraries from the weblogic-application.xml file.

For more information on referring to the shared libraries, see How to Create and Run a Sample Application by Using the Rules Dictionary Editor Component.

26.4.2.4 How to Run the Sample Task Flow Application

The last task is running the sample application in the embedded Oracle WebLogic Server.

To run the sample task flow application:

  1. To run the sample application, from Oracle JDeveloper, right-click the useRulesDictTaskFlow.jspx file.
  2. Select Run.

    This starts the sample application in a web browser, as shown in Figure 26-45.

    Figure 26-45 Running the Sample Rules Dictionary Editor Task Flow Application

    Description of Figure 26-45 follows
    Description of "Figure 26-45 Running the Sample Rules Dictionary Editor Task Flow Application"

26.4.3 How to Deploy a Rules Dictionary Editor Task Flow Application to a Standalone Oracle WebLogic Server

When you are ready to deploy your application EAR file to the standalone Oracle WebLogic Server, perform the following:

  1. Launch the Oracle WebLogic Server Administration Console (http://host:port/console/login/LoginForm.jsp).

  2. Ensure that oracle.rules is displayed in the deployments list.

  3. Ensure that oracle.soa.rules_dict_dc.webapp is displayed in the deployments list.

  4. If this is not displayed, click Install and select the JDEV_INSTALL/jdeveloper/soa/modules/oracle.soa.rules_dict_dc.webapp_11.1.1/oracle.soa.rules_dict_dc.webapp.war file.

  5. In the project that has to be deployed (where you create the EAR file):

    1. Add the following lines to the weblogic-application.xml:

      <library-ref>
         <library-name>oracle.rules</library-name>
      </library-ref>
      
    2. Add the following lines to weblogic.xml in the project WAR file:

      <library-ref>
         <library-name>oracle.soa.rules_dict_dc.webapp</library-name>
      </library-ref>
      
    3. Deploy the EAR file in Oracle WebLogic Server.

26.5 Localizing the ADF-Based Web Application

You can localize an application that is created using the Rules Editor component, Rules Dictionary Editor component, or Rules Dictionary Editor task flow.

To localize your application:

  1. Change the faces-config.xml in the application using the Rule Dict Editor component. The faces-config.xml file should have the following code within the <application> tag in order to support the available resource bundles:
    <locale-config>
          <default-locale>en</default-locale>
          <supported-locale>en</supported-locale>
          <supported-locale>ar</supported-locale>
          <supported-locale>cs</supported-locale>
          <supported-locale>da</supported-locale>
          <supported-locale>de</supported-locale>
          <supported-locale>el</supported-locale>
          <supported-locale>es</supported-locale>
          <supported-locale>fi</supported-locale>
          <supported-locale>fr</supported-locale>
          <supported-locale>hu</supported-locale>
          <supported-locale>it</supported-locale>
          <supported-locale>iw</supported-locale>
          <supported-locale>ja</supported-locale>
          <supported-locale>ko</supported-locale>
          <supported-locale>nl</supported-locale>
          <supported-locale>no</supported-locale>
          <supported-locale>pl</supported-locale>
          <supported-locale>pt-BR</supported-locale>
          <supported-locale>pt</supported-locale>
          <supported-locale>ro</supported-locale>
          <supported-locale>ru</supported-locale>
          <supported-locale>sk</supported-locale>
          <supported-locale>sv</supported-locale>
          <supported-locale>th</supported-locale>
          <supported-locale>tr</supported-locale>
          <supported-locale>zh-CN</supported-locale>
          <supported-locale>zh-TW</supported-locale>
        </locale-config>
    
  2. Change the browser language to the locale you are interested in.
  3. If you want to override the locale provided by the browser and display the UI in some particular locale then pass that locale as an attribute to the component and modify the f:view tag to the following in the application using the component.:
    <f:view locale="#{someBean.locale}">
    

    Note:

    The locale passed here should be same as the one passed to the component using 'locale' attribute.

26.6 Working with Translations

Translations feature supports translation of aliases in Business Rules Web UI.

You can have the aliases according to the locale. You can also edit the translations of aliases for different locales through translation tab or resource editor pop-up in Business Rules Web UI.

26.6.1 Enabling Translations for Consumer of Reusable Rules UI ADF Task Flow Component

To support translation of aliases, the consumers of reusable Rules UI ADF Task Flow component must provide locale specific resource artifacts as additional parameters while calling Rules UI ADF Task Flow. However, these additional parameters are optional and required only if the consumers want to use the enhanced translation support.

The additional parameters are:

property-name: relatedDetails
property-class: oracle.integration.console.metadata.model.share.IRelatedMetadataDetails
<taskFlow id="rulesdictflowdefinition1"
              taskFlowId="/WEB-INF/rule-dict-flow-definition.xml#rules-dict-flow-definition"
              activation="deferred" Refresh="default"
              RefreshCondition="${MyBean.refreshReqd}"
              xmlns="http://xmlns.oracle.com/adf/controller/binding">
 <parameter id="relatedDetails"
                   value="#{MyBean.relatedMetadataDetails}"/>
</taskflow>

26.6.1.1 Sample Code to Pass an Implementation of IRelatedMetadataDetails

The consumer has to pass an implementation of oracle.integration.console.metadata.model.share.IRelatedMetadataDetails

The implementation of IRelatedMetadataDetails contains the code for loading the resource bundles from the repository and also for saving the bundles files when user commits any change to rules application.

The consumer should use dictionaryName + "Translations_" + locale.toString() + ".xml" convention to build the name of the resource bundle file.

public class MyRelatedMetadataDetails implements IRelatedMetadataDetails {
 
  private static final Locale[] LOCALES = { Locale.US, Locale.FRENCH };
 
  private static final String RESOURCE_PATH =
    "file:///C:/scratch/sumit/system/rules/";
  private static final String RESOURCE_BASE = "SimpleRule";
 
  public MyRelatedMetadataDetails() {
    super();
  }
 
  public String getDocument(IRelatedMetadataPath relatedPath) {
    String resourceSuffix = relatedPath.getValue();
    try {
      return loadResource(resourceSuffix);
    } catch (IOException e) {
      return "";
    }
  }
 
  private static String loadResource(String resourceSuffix) throws IOException {
 
    FileInputStream fis = null;
    FileChannel fc = null;
    try {
      URL url = new URL(RESOURCE_PATH + RESOURCE_BASE + resourceSuffix);
      fis = new FileInputStream(url.getFile());
      fc = fis.getChannel();
      ByteBuffer bb = ByteBuffer.allocate((int)fc.size());
      fc.read(bb);
      bb.rewind();
      return Charset.defaultCharset().decode(bb).toString();
    } finally {
      if (fis != null) {
        fis.close();
      }
      if (fc != null) {
        fc.close();
      }
    }
  }
 
  public void createDocument(IRelatedMetadataPath relatedPath,
                             String document) {
    try {
      storeResource(relatedPath.getValue(), document);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 
  public void saveDocument(IRelatedMetadataPath path, String document) {
    try {
      storeResource(path.getValue(), document);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 
  private static void storeResource(String resourceSuffix,
                                    String document) throws IOException {
    FileOutputStream fos = null;
    FileChannel fc = null;
    try {
      URL url = new URL(RESOURCE_PATH + RESOURCE_BASE + resourceSuffix);
      fos = new FileOutputStream(url.getFile());
      fc = fos.getChannel();
      ByteBuffer bb = ByteBuffer.allocateDirect(1024);
      bb.clear();
      bb.put(Charset.defaultCharset().encode(document));
      bb.flip();
      while (bb.hasRemaining()) {
        fc.write(bb);
      }
    } finally {
      if (fos != null) {
        fos.close();
      }
      if (fc != null) {
        fc.close();
      }
    }
  }
 
  public IRelatedMetadataPathFinderFactory getFinderFactory() {
    return new RelatedMetadataPathFinderFactory();
  }
 
  public List<IRelatedMetadataPath> getExisting(IRelatedMetadataPathFinder finder) {
 
    List<IRelatedMetadataPath> paths = new ArrayList<IRelatedMetadataPath>();
    for (Locale locale : LOCALES) {
      paths.add(RelatedResourceMetadataPath.buildFromLocale(locale));
    }
    return paths;
  }
 
  public class RelatedMetadataPathFinderFactory implements IRelated`MetadataPathFinderFactory {
 
    public IRelatedMetadataPathFinder getResourceFinder() {
      return new RelatedMetadataPathFinder();
    }
  }
 
  public class RelatedMetadataPathFinder implements IRelatedMetadataPathFinder {
 
    public String getType() {
      return null;
    }
 
    public IRelatedMetadataPath matches(oracle.integration.console.metadata.model.share.MetadataPath srcPath,
                                        oracle.integration.console.metadata.model.share.MetadataPath matchPath) {
      return null;
    }
  }
 
}

26.6.2 Enabling Translations for Consumer of Rules Web UI Application

To support translation of aliases, the consumer of Rules Web UI application must pass an attribute to the Rules Dictionary DC or Rules DC. The attribute is resourceManager which accepts an instance of type oracle.bpel.rulesshareddc.model.interface.ResourceManagerInterface.java. However, this additional parameters are optional and required only if the consumers want to use the enhanced translation support.

<rddc:ruleDictionaryDC ruleDictModel="#{SomeBean.ruleDictModel1}"
  id="rddc1"
   resourceManager="#{SomeBean.resourceManager}">
  </rddc:ruleDictionaryDC>
26.6.2.1 Sample Code for Creating an Instance of resourceManager

Implementation of ResourceManagerInterface is provided as oracle.bpel.rulesshareddc.model.impl.ResourceManager. Consumers may create an instance of ResourceManager and pass it to corresponding UI component.

Note:

The consumer has to load all the saved resource bundles from the repository and should construct a java.util.Map (resourceMap) where java.util.Locale of the resource bundle is kept as key and the content of the resource bundle file as value which is of type java.lang.String.

The consumer should use dictionaryName + "Translations_" + locale.toString() + ".xml" convention to build the name of the resource bundle file.

The consumer has to save these resource bundles to the repository whenever the user commits any change in the application.

public ResourceManagerInterface getResourceManager() {
    if (resourceManager == null) {
      resourceManager =
          new ResourceManager(loadResources(), ruleDictionary);
    }
    return resourceManager;
  }
 
  private Map<Locale, String> loadResources() {
 
    Map<Locale, String> resourceMap = new HashMap<Locale, String>();
 
    for (Locale locale : LOCALES) {
      try {
        URL url =
          new URL(RULES_FILE_PATH + "Translations_" + locale.toString() +
                  ".xml");
        String content =
          new Scanner(new File(url.getFile()), "UTF-8").useDelimiter("\\A").next();
        resourceMap.put(locale, content);
      } catch (IOException e) {
        resourceMap.put(locale, "");
        LOG.severe("Failed to load resource:" + e.getMessage());
      }
    }
    if (!resourceMap.keySet().contains(getLocale())) {
      resourceMap.put(getLocale(), "");
    }
    return resourceMap;
  }
 
  private void storeResources(Map<Locale, String> resourceMap) {
    for (Locale locale : resourceMap.keySet()) {
      try {
        URL url =
          new URL(RULES_FILE_PATH + "Translations_" + locale.toString() +
                  ".xml");
        BufferedWriter out = new BufferedWriter(new FileWriter(url.getFile()));
        out.write(resourceMap.get(locale));
        out.close();
      } catch (IOException e) {
        LOG.severe("Failed to store resource:" + e.getMessage());
      }
    }
  }