donderdag 8 juli 2010

Form caching of frequently called non-display method

To cache a method on a form, it must be a display method.
How do we cache a method "myMethod" that is NOT a display method?
We cannot use cacheAddMethod.

In general:
Classdeclaration:
Create a map that with
key = the recid of the current record of the form datasource
and value = the return value of "myMethod"

ExecuteQuery:
Empty your map.
suppose "myMethod" returns a string:

myMap = new Map(Types::Integer, Types::String)


[location where method is called]:
Look in the map if the recid exists.
If it exists, return that value.
If not exists, execute "myMethod", store in myMap with current recId, and return that value.

ReRead:
Remove the current recid from the map, so that the method will be re-executed next time.
 

Geen opmerkingen:

Een reactie posten