How to process fetch data request information in a dynamic business entity
Description
Starting with version 23.18.0, it is now possible to process the request information of a fetch data request in the Dynamic Business Entity event handler.
The fetch data request information is available using the FetchDataRequest property available through the base server event handler class.
The property is an object with the following relevant properties:
- NumRecords: number of records requested
- Queries: a standard OpenEdge filter containing all the filters requested by the client
- NamedQuery: a custom object with a name and list of parameters
How to use it
How to process the Queries property:
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS Sample.SampleServerEventHandler
INHERITS Akioma.Swat.OERA.Dynamic.BaseServerEventHandler:
{ Sample/dsData.i &ACCESS="PRIVATE" }
CONSTRUCTOR SampleServerEventHandler():
SUPER(DATASET dsData:HANDLE).
THIS-OBJECT:TriggerOnAfterFetch = TRUE.
END CONSTRUCTOR.
METHOD PROTECTED OVERRIDE VOID OnAfterFetch():
DEFINE VARIABLE cFilterValue AS CHARACTER NO-UNDO.
cFilterValue = Akioma.Swat.Util.QueryParserHelper:GetQueryConditionCharacterValue(THIS-OBJECT:FetchDataRequest:Queries, "eData.MyField").
IF cFilterValue NE ? THEN
MESSAGE "Filtering MyField by" QUOTER(cFilterValue).
END METHOD.
END CLASS.
On the frontend, the filter criteria is set automatically through specialized controls, like the grid. But they can also be set from client logic by using the ‘setFilter’ method on the data source object.
How to process the NamedQuery property:
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS Sample.SampleServerEventHandler
INHERITS Akioma.Swat.OERA.Dynamic.BaseServerEventHandler:
{ Sample/dsData.i &ACCESS="PRIVATE" }
CONSTRUCTOR SampleServerEventHandler():
SUPER(DATASET dsData:HANDLE).
THIS-OBJECT:TriggerOnAfterFetch = TRUE.
END CONSTRUCTOR.
METHOD PROTECTED OVERRIDE VOID OnAfterFetch():
DEFINE VARIABLE cParameter AS CHARACTER NO-UNDO.
IF VALID-OBJECT(THIS-OBJECT:FetchDataRequest:NamedQuery) THEN
CASE THIS-OBJECT:FetchDataRequest:NamedQuery:Name:
WHEN "NamedQuery1" THEN
DO:
IF THIS-OBJECT:FetchDataRequest:NamedQuery:Parameters:ContainsKey("MyCustomParameter") THEN
cParameter = THIS-OBJECT:FetchDataRequest:NamedQuery:Parameters:GetParameterValueAsCharacter("MyCustomParameter").
MESSAGE "Processing data request with 'NamedQuery1' and parameter value" cParameter.
END.
END CASE.
END METHOD.
END CLASS.
On the frontend, the named query information can be set from client logic by using the ‘setNamedQueryParam’ method on the data source object.
Back to Documentation
Back to Home Page