Using SPEL to trigger personalizations
SPEL stands for Simplest Possible Expression Language. A SPEL statement will return a Boolean value of either True
or False
and can be used for conditionally setting a property of an item on a page.
Adding a SPEL statement
In this recipe, we are going to use SPEL to set the properties of an item. We are going to set the Read Only property based on a SPEL statement. If the SPEL statement returns True
, the item will be made read only to the user.
How to do it...
To set properties using SPEL, perform the following steps:
Log in to Oracle with
XXUSER
and select the XX Test Manager Self-Service responsibility.Navigate to the Absence Management page.
Click on the Action icon for an employee record.
Click on the Create Absence button.
Click on the Personalize Page link.
Click on the Complete View radio button.
Click on the Expand All link.
Press Ctrl + F to bring up the search facility on the browser.
Type in
Comments
and scroll down to the Message Text Input: Absence Comments record (which will be highlighted from the find).Click on the Personalize icon.
Click on the Choose Levels Displayed button.
Shift all of the items other than Site and Responsibility back to the Available Levels side.
Click on the Apply button.
Set the Read Only property at the Responsibility level to SPEL.
Set the Responsibility level for the SPEL statement to ${oa.FunctionSecurity.XXABSREADONLY}, as shown in the following screenshot:
Click on the Apply button.
Scroll down to the bottom of the page and click on the Return to Application link.
How it works...
You may notice that the comments item is now not displayed on the screen. This is because we need to create the function and add it to the menu for the SPEL condition to be returned.
Creating a function
We are now going to create a function that we will add to a menu.
How to do it...
To create a function, perform the following steps:
Log in to Oracle with
XXUSER
and select the Application Developer responsibility.Navigate to Application | Function.
Create a function with the following details:
Item name
Item value
Function
XXABSREADONLY
User Function Name
XX Absence Read Only
Description
XX Absence Read Only
Type
Subfunction
The function will be displayed as shown in the following screenshot:
Save the record and dismiss the confirmation message.
Adding a function to a menu
We will now add a function to a menu attached to the XX Test Manager Self Service responsibility. The function will be present in the menu, which will mean that the SPEL statement will return True
.
How it works...
To add a function to a menu, perform the following steps:
Log in to Oracle with
XXUSER
and select the Application Developer responsibility.Navigate to Application | Menu.
Query back the Manager Self Service menu.
Add the function XXABSREADONLY to the menu with the following details:
Item name
Item value
Seq
200
Function
XX Absence Read Only
Save the menu and dismiss the confirmation message to compile the menu.
We can see that the function has now been added to the menu as shown in the following screenshot: