...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
DEFINE {&ACCESS} TEMP-TABLE eTestSessionContext{&SUFFIX} NO-UNDO {&REFERENCE-ONLY} &IF DEFINED (NO-BEFORE) EQ 0 &THEN BEFORE-TABLE eTestSessionContextBefore{&SUFFIX} &ENDIF FIELD TestProperty1 AS CHARACTER FIELD TestProperty2 AS CHARACTER . |
Next, a context wrapper class needs to be defined to provide access to the eTestSessionContext table fields.
For the SmartComponent Library session, the properties are available by accessing Consultingwerk.OERA.ContextWrapper.
For the SWAT session, the properties are available by accessing Akioma.Swat.OERA.Context.SwatContextWrapper.
A similar class should be implemented to provide strong-typed access to the custom session properties.
Both the SmartComponent Library and the SWAT context wrappers are separated into 2 different classes, the wrapper and the wrapper implementation (ex. Consultingwerk.OERA.ContextWrapper and Consultingwerk.OERA.ContextWrapperImpl), but this is not a requirement.
To simplify the implementation, we provide a base class for the implementation class: Akioma.Swat.OERA.Context.BaseContextWrapperImpl.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
INTERFACE Test.ITestContextWrapper: DEFINE PUBLIC PROPERTY TestProperty1 AS CHARACTER NO-UNDO GET. SET. ?? DEFINE PUBLIC PROPERTY TestProperty2 AS CHARACTER NO-UNDO GET. SET. END INTERFACE. |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
USING Progress.Lang.*. USING Test.ITestContextWrapper FROM PROPATH. USING Akioma.Swat.OERA.Context.BaseContextWrapperImpl FROM PROPATH. USING Akioma.Swat.SessionManager FROM PROPATH. BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS Test.TestContextWrapperImpl INHERITS BaseContextWrapperImpl IMPLEMENTS ITestContextWrapper : DEFINE PUBLIC PROPERTY TestProperty1 AS CHARACTER NO-UNDO GET (): IF NOT IsValidateSessionContext ("Get":U) THEN RETURN ?. RETURN GetSessionContextField ("TestProperty1"):BUFFER-VALUE . END GET . SET (arg AS CHARACTER): IsValidateSessionContext ("Set":U). GetSessionContextField ("TestProperty1"):BUFFER-VALUE = arg . END SET. ?? DEFINE PUBLIC PROPERTY TestProperty2 AS CHARACTER NO-UNDO GET (): IF NOT IsValidateSessionContext ("Get":U) THEN RETURN ?. RETURN GetSessionContextField ("TestProperty2"):BUFFER-VALUE . END GET . SET (arg AS CHARACTER): IsValidateSessionContext ("Set":U). GetSessionContextField ("TestProperty2"):BUFFER-VALUE = arg . END SET. CONSTRUCTOR TestContextWrapperImpl(): SUPER(). THIS-OBJECT:ContextTableName = "eTestSessionContext". END CONSTRUCTOR. END CLASS. |
...
Once all the classes are available the services file needs to be updated to use them:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ttServiceLoaderRow> <Order>210</Order> <ServiceTypeName>Consultingwerk.Framework.Server.IContextDatasetStore</ServiceTypeName> <ServiceClassName>Akioma.Swat.OERA.Context.SwatContextDatasetStore</ServiceClassName> </ttServiceLoaderRow> <ttServiceLoaderRow> <Order>211</Order> <ServiceTypeName>Consultingwerk.OERA.Context.IContextDatasetFactory</ServiceTypeName> <ServiceClassName>Test.TestContextDatasetFactory</ServiceClassName> </ttServiceLoaderRow> |
...
Additionally, we provide a new web handler which returns the session, which requires the 'ContextName' path portion.
The ContextName will need to be one of the tables from the session dataset: eSessionContext (SmartComponentLibrary), eSwatSessionContext (SWAT), eTestSessionContext (Sample)
Code Block | ||
---|---|---|
| ||
handler15=Akioma.Swat.OERA.WebHandler.SwatSessionContextWebHandler: /SessionContext/{ContextName} |
See how to work with session properties from the front-end here.