יום שני, 19 במאי 2014

Siebel Open UI: Format All the Lists - Part 1

In an attempt for a real-life scenario of customizing the appearance of all list applets in a Siebel Open UI enabled application, I would like to introduce you to a coding experiment for conditional formatting of list columns.

As usual, let's see what we want to achieve:

Click to enlarge.
As you can see from the above screenshot, the Opportunity List Applet has two columns - Revenue and Probability % - which are conditionally formatted depending on their value. End users are able to use CTRL+click on the column header to display a prompt where they can enter a target value to influence the background color of the cells.

This solution should be applicable to all list applets. In this and the following post, I will lay out the steps to achieve a generic solution for the requirement presented above. The example solution focuses on numeric columns but can be easily applied to other data types as well.

The following are the main ingredients:

  • Applet User Properties
  • Custom Presentation Model
  • Custom Physical Renderer

Today, we'll focus on the first two points:

Using Custom Applet User Properties in Siebel Open UI

As a frequent reader of this blog, you are aware of the ClientPMUserProp applet user property introduced with Innovation Pack 2013. This user property is used by Oracle to define standard applet behavior such as drag and drop to and from list applets or collapsible/expandable headers.

We can also define our own custom user properties and - as they will be forwarded to the Open UI framework - can use them in the browser-side code to control the behavior of our customizations.

To implement the conditional formatting example, I chose to define two custom user properties:

  • CF Field List: A comma separated list of business component fields which - should they be exposed as list columns - will be conditionally formatted.
  • CF Threshold List: A comma separated list of numeric values which defines the default target values for the respective fields.

To add these user properties to an applet, we have to edit the applet in Siebel Tools and do the following:

  1. Open the list of Applet User Properties for the applet.
  2. Create three new user property records as follows:



Name
Value
ClientPMUserProp
CF Field List, CF Threshold List
CF Field List
Primary Revenue Amount,Primary Revenue Win Probability
CF Threshold List
500000,50

The above settings apply to any list applet using the Opportunity business component, for example the Opportunity List Applet.

Here is a screenshot documenting the work:

Click to enlarge.
We have to consider that when the ClientPMUserProp user property is already defined for an applet, we must add our new user properties to the list, using commas as the separator. Alternatively, the user property can be sequenced, so we can define multiple instances like ClientPMUserProp1, ClientPMUserProp2 and so forth.

With this technique we can define a list of fields which should be conditionally formatted and the default target value for any list applet. Of course the field names must match exactly those of fields available in the applet's BC.

Ah, and yes, don't forget to compile the applet(s).

Accessing Custom User Properties in a Presentation Model

Any user property defined in the ClientPMUserProp value will be propagated to the property set used to set up the presentation model of the UI object.

As Siebel Bookshelf states, we can currently do this with individual controls, applets or views. To be able to access the values of the custom user properties, we must extend the presentation model and override the Setup method of the custom PM. This is because the Setup method receives a reference to the current object's property set.

The following code shows the Setup method of a custom presentation model extension class, accessing the user properties we created above.

Click to enlarge. Example code for IP 2013 (8.1.1.11)
The screenshot shows the full code with the important lines highlighted.

As you can see, we use a reference to the Oracle-defined set of constants to retrieve the name of the property set containing the applet user properties (SWE_APPLET_PM_PS). This is a recommended practice to avoid issues should Oracle engineering decide to change the naming convention in a future release.

Then we can use the GetProperty method of the property set to retrieve the values of the two custom user properties we created in the first step in Siebel Tools and store them as "local" PM properties so that we can easily access them from the physical renderer.

The custom presentation model must be administered in the manifest as usual and associated with a test list applet (recommended) and later with the DEFAULT LIST APPLET entry (IP 2013 and later). For testing purposes it is recommended to use a single test applet and use SiebelJS.Log() to print the user property values to the browser's JavaScript console.

The Story so far

With the above configurations, we have set the foundation for writing a generic physical renderer extension for list applets which evaluates the user properties and formats the respective list columns accordingly.

Please stay tuned for the second part of this mini-series where we will discuss a possible approach for this solution.

have a nice day

@lex

אין תגובות:

הוסף רשומת תגובה