WebSphere Portal, Express Beta Version 6.1
Operating systems: i5/OS, Linux,Windows


 

Programmatically invoking rules

All types of rules can be accessed programmatically within a Java application. For example, a profiler can be used to determine the behavior an application should exhibit depending on the current user, or an action can return content to your application for further processing before the content is displayed.

Rules are mapped to content spots, and because a content spot is an implementation of a JavaBean, it can be programmatically declared and implemented.

To programmatically invoke a rule:

  1. Instantiate the bean. If the class name of your content spot was ProfilerSpot, you would instantiate the bean using one of the options below.
    com.ibm.websphere.personalization.ContentSpot contentSpot = 
      new com.ibm.websphere.personalization.ContentSpot(“ProfilerSpot”);

    or

    ProfilerSpot contentSpot = new ProfilerSpot();
  2. Call the method setRequest() and pass the HttpServletRequest object or an object that implements PznRequestObjectInterface. This makes current information stored in the request object known to the Personalization Runtime Engine and the Resource Engine.
    contentSpot.setRequest(request); 
  3. Trigger the rule and, if applicable, get the content from the rule. Use one of the methods below depending on the type of rule.

Parent topic: Personalization programming reference
Library | Support | Terms of use |