Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleSample: eTestSessionContext
linenumberstrue
collapsetrue
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
titleSample: TestContextWrapperImpl
linenumberstrue
collapsetrue
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
titleSample: Service file entries
linenumberstrue
collapsetrue
	<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)

...