Business Context
A business context of the portal is a set of properties that will be made available in a centralized manner. A context is defined by a file called contextdefinition.xml. The reference for this file is the XSD contextdefinition.xsd, which must use the location http://www.lumis.com and is found in the product distribution at def/lumis/portal/businesscontext/contextdefinition.xsd.
The basic structure of the context definition file is as follows:
Each property (node property) must have one of the following nodes:
- fixed: used to expose a fixed value in the context.
- expression: used to expose the value of an EL (expression language) in the context.
- custom: used to customize the retrieval of the value to be exposed in the context.
Fixed Values in the Context
To expose a fixed value in the context, a parameter can be defined as:
Where value is the value
to be exposed.
EL Values in the Context
To expose EL values in the context, a parameter can be defined as:
Where el
is the EL to be exposed. The available variables are listed in Available Resources in EL, marked with the LayoutFile scope. The variable pageWebResource
, however, is not available.
In addition to these variables, the following variables are available:
groupsHash
: returns a hash of the current user’s groups.lum_device
: returns the device that is accessing the portal.lum_campaign
: returns marketing campaign information from the initial access.lum_geoLocation
: returns geolocation information of the current user.
The available functions are:
isMemberOf(String groupAlias)
: Returns whether the current user belongs to the given group. In other words, returns true if there exists a group G such that the alias of G is equal to the provided parameter.groupsHash()
: Returns a hash with the groups that the user belongs to.
Custom Values in the Context
To expose custom values in the context, it is necessary to define the <custom>
element specifying
the class that implements IBusinessContextValueProvider
using the className
attribute.
If the className
attribute is specified, it must contain the fully qualified name of the Java class
that implements IBusinessContextValueProvider
.
In the definition of the custom property, parameters can be passed to be used in calculating the value to be exposed, as in the following example:
In this case, lumis.portal.businesscontext.example.HelloWorldContextValueProvider
is the fully qualified name of the custom class to be used. This class must implement lumis.portal.businesscontext.IBusinessContextValueProvider
. For better future compatibility, it is recommended to extend the abstract class lumis.portal.businesscontext.AbstractBusinessContextValueProvider. The interface defines the following methods:
public String get(HttpServletRequest request)
: Method used to calculate the property value for the request.public void initialize(Map<String, String> parameters)
: Initialization method that receives a map of optional parameters passed in the parameters node within the custom node. In the example, this map would be: {name
=World
}.
Below is an example implementation:
In this example implementation, the value of the property would be "Hello, World", where World
is the parameter with the name name
.
For more information, see the API Java and XSD.
Usage Examples
To expose the user's device in the property device.os
:
To expose the user's device type in the property device.type
:
To expose the user's groups hash in the property groups.hash
:
To expose whether the user belongs to any group in the property is.member.of.alias
:
To expose the marketing campaign name in the property campaign.name
:
To expose the marketing campaign term in the property campaign.term
:
To expose the medium in which the marketing campaign was shared in the property campaign.medium
:
To expose the source of the marketing campaign in the property campaign.source
:
To expose the content of the marketing campaign in the property campaign.content
:
To expose the code referring to the User's country geoLocation.country
:
To expose the code referring to the User's state geoLocation.state
:
To obtain the current context in the context of an interface (i.e., in a control, in a process action, in a data provider, etc.), simply use the method getBusinessContext()
of the interface request, for example:
In a process action or control:
In a data provider :
```