Application object | HCL Digital Experience

An application object is a java object existing at a known location in the request context. Defining an application object involves specifying the object’s class name (as a Java class), and specifying a key (string key into a session attribute) to find it in the request context. Personalization calls methods on these objects during rule execution and uses their results in its decision making. Application Objects that implement the SelfInitializingApplicationObject interface are automatically instantiated as needed by Personalization.

Installed application objects

The Device, Referrer, Public Render Parameter, and Shared Data application objects are installed by default. By using installed application objects, you can skip the process of defining and registering application objects.

When you use application objects that are not installed, you must define the application objects by using a set of Personalization wizards that are provided with IBM® Rational® Application Developer or develop application objects according to a set of public programming interfaces. After you define the application objects, the application objects are registered to the Personalization server through the Personalization browser. When you use the installed application objects, you do not have to define or register the application objects.

The Device, Referrer, Public Render Parameter, and Shared Data application objects are installed and enabled with 8.5.
Optional: To enable the Content Targeting Dialog in virtual portals, use XML access to manually create the hidden Content Targeting Dialog page for each virtual portal. From the wp_profile_root/ConfigEngine directory, run the following task:
  • AIX® HP-UX Linux Solaris z/OS®: ./xmlaccess.sh -in PortalServer_root/pzn.ui/wp.pzn.ui.actions/config/templates/DeployPages.xml -url http://localhost:10039/wps/config/your_virtual_portal_context -user admin_user_id -password admin_password
  • IBM® i: xmlaccess.sh -in PortalServer_root/pzn.ui/wp.pzn.ui.actions/config/templates/DeployPages.xml -url http://localhost:10039/wps/config/your_virtual_portal_context -user admin_user_id -password admin_password
  • Windows: xmlaccess.bat -in PortalServer_root\pzn.ui\wp.pzn.ui.actions\config\templates\DeployPages.xml -url http://localhost:10039/wps/config/your_virtual_portal_context -user admin_user_id -password admin_password

The following topics contain an overview of the installed application objects. This overview includes descriptions and examples of using the application objects in rules that you create. To select the attributes that are used in the examples, you must enable the application objects. Instructions for enabling the location attributes associated with the Device application are also included in this section.

Accessing arbitrary request headers in rule conditions

In PZN rules it is possible to access various dynamic attributes - e.g. session data or request data. For the request object it was possible up to now to look for request attributes - as for instance set by a portlet or theme or other code.

With 205 it is now possible to access arbitrary request headers as well.

Enabling

To not change the existing behavior the feature is disabled by default and needs to be activated:

For that set the following new attribute in the WP ConfigService Resource Environment Provider:
evaluateRequestHeadersForPZN=true

Script portlet sample code

The following sample code shows how a header could be inserted to check a condition for that header in a rule.

The corresponding rule:

Profile User Rule 1 is
 
  Mike  when
 
    current Request.test  is  test
 
  Otherwise  Thomas
The script portlet sample code:
  • HTML:
    
    <div id='pzn'>Hello World</div>
    
    <button type="button" id="myBtn">Check Profile</button>
  • Javascript (need to adjust the host and port and rule UUID accordingly):
    
    document.getElementById("myBtn").onclick = () => {
            fetch("http://localhost:10039/wps/contenthandler/pzn-rest/rules/b1820994-0dfa-4115-81ac-6bea0a4bacdf/invoke", {
            method: 'post',
            body: '{}',
            headers: {
                'Accept': 'application/json, text/plain, */*',
                'Content-Type': 'application/json',
                'test':'test'
                },
            })
              .then((data) => {
                return data.json();
              }).then((res) => {
                console.log(res.result[0]);
                if(res.result[0]==="Thomas")
                    document.getElementById("pzn").innerHTML = "Thomas";
                else
                    document.getElementById("pzn").innerHTML = "Mike";                  
              }).catch(err=>{
              // log errors
              console.log(err);
            })
          };

The following topics contain an overview of the installed application objects. This overview includes descriptions and examples of using the application objects in rules that you create. To select the attributes that are used in the examples, you must enable the application objects. Instructions for enabling the location attributes associated with the Device application are also included in this section.