Due to the nature of the web architecture things such as displaying a progress dialog or a wait dialog has become a little more difficult

We have the two parts to the application. A DataFlex program that runs on the web server and serves any number of requests from different clients and the Javascript code that executes on the client side in the browser.

In case of a simple example lets say we have a button on the screen that executes some code when clicked that could take a little while. We want the user to know that there is a small wait involved so they do not think that something is wrong.

What happens in detail is that the user clicks on the button in the web page. That button calls its click event in the client javascript code. The client code will then call the server and execute the OnClick procedure in the DataFlex code on the server.

The DataFlex code doesnt return back to the client until it finishes so it isnt possible to update the user interface which would require another round trip back to the client.

Instead DataFlex has added the SetActionMode method to define a progress user interface before things are happening

Essentially what you are doing is to tell DataFlex that if the client code were to call the buttons OnClick procedure you want to progress user interface to show.

This can be done in the OnLoad method of the object that is going to be called later in our case the button

Procedure OnLoad
    Forward Send OnLoad
        
    Send SetActionMode (RefProc(OnClick)) scModeWait ""
End_Procedure

The code above tells DataFlex that the client code calls the OnClick procedure you want to show the wait Cursor. Another option is to show the progress dialog using szModeProgress .

Send SetActionMode (RefProc(OnClick)) scModeProgress "Please Wait"

As mentioned earlier the method that has to be passed to SetActionMode is the one called by the client code and cant be another method that might be called later.

For example

Procedure MyMethod
  ...
End_Procedure

Procedure OnClick
    Send MyMethod
End_Procedure

Procedure OnLoad
    Forward Send OnLoad
        
    Send SetActionMode (RefProc(MyMethod)) scModeWait ""
End_Procedure

the above will not work as the MyMethod is called from server side DataFlex code not client code.

When calling a YesNo box for example you need to specify the proper method

Procedure YesNoCallback Integer eConfirmMode
    ....
End_Procedure

Procedure OnLoad
    Send SetActionMode (RefProc(YesNoCallback)) scModeWait ""
End_Procedure

Procedure OnClick
    Send ShowYesNo (Self) (RefProc(YesNoCallback)) "Question?" "Question?"
End_Procedure
Michael Salzlechner is the CEO of StarZen Technologies, Inc.

He was part of the Windows Team at Data Access Worldwide that created the DataFlex for Windows Product before joining StarZen Technologies. StarZen Technologies provides consulting services as well as custom Application development and third party products specifically for DataFlex developers