- Session Properties: Backend
- How to setup Custom session properties
- Session Properties: Frontend
- Accessing session properties from front-end via CLAPI
- Updating session context via CLAPI
Session Properties: Backend
If you want to read the session properties with ABL, you can use Akioma.Swat.OERA.Context.SwatContextWrapper
The following properties are available:
- SwatSessionId
- UserHdl
- UserKey
- UserDesc
- TenantHdl
- TenantKey
- TenantName
- UiLanguageHdl
- UiLanguageKey
- DataLanguageHdl
- DataLanguageKey
E.g to get the current user please use Akioma.Swat.OERA.Context.SwatContextWrapper:Properties:UserHdl
For the current session-id you can use the helper class Akioma.Swat.Util.
SessionHelper
:GetCurrentRequestSessionId()
How to setup Custom session properties
- Set up context dataset and temp-table:
- Set up context dataset factory:
- Set up context wrapper class:
- Register context classes as services
&SCOPED-DEFINE ACCESS {&ACCESS}
{ Consultingwerk/OERA/Context/eContextProperties.i &NO-BEFORE=YES }
{ Consultingwerk/OERA/Context/eSessionContext.i &NO-BEFORE=YES }
{ Akioma/Swat/OERA/Context/eSwatSessionContext.i &NO-BEFORE=YES }
DEFINE {&ACCESS} TEMP-TABLE eTestSessionContext NO-UNDO
FIELD Property1 AS CHARACTER
FIELD Property2 AS CHARACTER
.
DEFINE DATASET dsTestContext FOR eContextProperties, eSessionContext, eSwatSessionContext, eTestSessionContext.
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS Test.TestContextDatasetFactory
INHERITS Akioma.Swat.OERA.Context.BaseContextDatasetFactory:
{ Test/dsTestContext.i }
CONSTRUCTOR TestContextDatasetFactory():
SUPER(DATASET dsTestContext:HANDLE).
END CONSTRUCTOR.
END CLASS.
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS Test.TestContextWrapper
INHERITS Akioma.Swat.OERA.Context.BaseContextWrapper:
{ Akioma/Swat/OERA/Context/Helper/define-context-wrapper-property.i &NAME="Property1" }
{ Akioma/Swat/OERA/Context/Helper/define-context-wrapper-property.i &NAME="Property2" }
CONSTRUCTOR TestContextWrapper():
SUPER("eTestSessionContext").
END CONSTRUCTOR.
END CLASS.
<?xml version="1.0"?>
<ttServiceLoader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ttServiceLoaderRow>
<Order>1</Order>
<ServiceTypeName>Test.TestContextWrapper</ServiceTypeName>
<ServiceClassName>Test.TestContextWrapper</ServiceClassName>
</ttServiceLoaderRow>
<ttServiceLoaderRow>
<Order>5</Order>
<ServiceTypeName>Consultingwerk.OERA.Context.IContextDatasetFactory</ServiceTypeName>
<ServiceClassName>Test.TestContextDatasetFactory</ServiceClassName>
</ttServiceLoaderRow>
</ttServiceLoader>
Session Properties: Frontend
Accessing session properties from front-end via CLAPI
Starting with the SWAT 19.17 release, you can access the session properties from the front-end.
The new SessionContext is available by accessing akioma.sessionContext
. Here the eSessionContext (SCL) and eSwatSessionContext are available. Any custom context would be available in the same object (e.g eCustomSessionContext).
The SessionContext can also be accessed from CLAPI:
akioma.swat.SessionManager.get('propertyName', 'context');
// If 'context' is not specified, default will be eSwatSessionContext.
Updating session context via CLAPI
The SessionContext properties can also be updated from CLAPI using the following method:
akioma.swat.SessionManager.set('propertyName', ‘propertyValue’, 'context');
// If 'context' is not specified, default will be eSwatSessionContext.
See how to work with session properties from the back-end .
Back to Documentation
Back to Home Page