Page 1 of 1

VLF-ONE Command Handler Free and Busy State

Posted: Wed Feb 22, 2017 3:28 am
by jyoung
When executing a command handler, when does the busy/free state get toggled?

I have a command handler and inside the uExecute method I perform an asynchronous call to a server module for data.
If I don't specify any additional GoToBusy/Free state commands, a brief "loading" shroud covers the filter and instance list, then the command handler is shown, then my data is populated on screen.

There is a very noticeable delay between the command handler showing and the data showing.

To rectify that, I tried putting the the GoToBusy/Free state commands at the appropriate points (similar to the Filter) but it appears to have no effect. Is that the expected behavior? Am I putting the state commands in the wrong place?

Here is the execute method.

Code: Select all

mthroutine name(uExecute) options(*REDEFINE)
define_com class(#PRIM_BOLN) name(#returnCode)
define_com class(#VF_LM003O) name(#dataItem) reference(*DYNAMIC)

* Define the data service
define_com class(#CMGCCPServerModule.GetSummary) name(#summary)

* Clear any previous messages
#avFrameworkManager.avClearMessages requester(#COM_OWNER)

*  Do any execution logic defined in the ancestor
#COM_ANCESTOR.uExecute gotofreestate(#GotoFreeState) switchcallerreference(#SwitchCallerReference)

group_by name(#dataFields) fields(#CLDFB #l_LastBillDate #l_PreviousBillDate)

#dataItem <= #COM_OWNER.avAssociatedInstance

if (#dataItem *IsNot *NULL)

#ListManager.GetIdentifiers( #dataItem #CLOFID #CLOCN #CLOD )

#COM_OWNER.avGotoBusyState showbusytext("**************** LOOK AT ME *********************") animated(False)

* Get the data from the server by doing a asynchronous call to the Data service Server Module
#avFrameworkManager.avRecordTrace component(#COM_OWNER) event("Executing GetSummary")
#summary.ExecuteAsync officenumber(#CLOFID) controlnumber(#CLOCN) departmentcode(#CLOD) summaryfields(#dataFields)

else
#avFrameworkManager.avIssueMessage text('No current item found') requester(#COM_OWNER)
endif

* Button will be enabled when a field is changed
#SaveButton.Enabled := False

evtroutine handling(#summary.Completed)

#avFrameworkManager.avRecordTrace component(#COM_OWNER) event("GetSummary Completed")

#STD_DATEX := #CLDFB.AsDate( CCYYMMDD )
#FirstBillDate := #STD_DATEX.AsDisplayString( MMsDDsCCYY )

#STD_DATEX := #l_LastBillDate.AsDate( CCYYMMDD )
#LastBillDate := #STD_DATEX.AsDisplayString( MMsDDsCCYY )

#STD_DATEX := #l_PreviousBillDate.AsDate( CCYYMMDD )
#PreviousBillDate := #STD_DATEX.AsDisplayString( MMsDDsCCYY )

* if no data, then issue message
* #avFrameworkManager.avIssueMessage text('Not found on Server') requester(#COM_OWNER)

#COM_OWNER.avGotoFreeState
endroutine

evtroutine handling(#summary.Failed) reason(#reason) handled(#handled)
#avFrameworkManager.avRecordTraceAValue component(#COM_OWNER) event("GetSummary Failed") avalue(#reason)
* stop the event from bubbling up
#handled := True
#avFrameworkManager.avIssueMessage text('Could not retrieve data from server') requester(#COM_OWNER)
endroutine

endroutine
Is it possible to manage the Busy/Free state in VLF-ONE? How do I go about telling the framework to go the free state AFTER data is loaded?

Re: VLF-ONE Command Handler Free and Busy State

Posted: Wed Feb 22, 2017 8:32 am
by MarkD
A uExecute method is normally handled like this by the framework:
• Go to busy state
• Invoke #CommandHandler.uExecute
• If parameter #GotoFreeState is returned as true, then go back into free state.
By default, #GotoFreeState is returned as true.

That means you don’t need to put the command handler pane into busy state because it has already been done for you.
You can remove that from your uExecute routine.

If you want to decide yourself when to go back into free state (as you do into this case) add the line #GotoFreeState := False into your uExecute method. In your case you’d probably only do that when decide to execute the async server module. When you issue the item not found message you would probably leave it as true and let the framework drop the busy state automatically.

When you are ready to go back to free state after the serve module has completed use #COM_OWNER.avGotoFreeState.

Note that free state changes, just like any other visual changes to a VL-Web display, do not appear until your code completes execution.