Oracle JET Busy Context API to Control Asynchronous REST Calls by Andrejus Baranovskis

Posted: March 7, 2018 in JDeveloper & ADF
Tags: , , , , , , ,

I have received feedback from users working with JET UI – sometimes it is not obvious that action button was pressed, users tend to press same button again very fast, which leads to parallel REST calls executing at the same time. In JET – REST call is executed asynchronously, this makes user to believe action was done instantly when button was pressed. However, REST call still may run in the background – while user will be trying to call same service again. While in most of the cases such behaviour is fine, still there are use cases when we want to block action button, until REST response is not received (while response is executed, button will be disabled – this will give visual feedback to the user about action still executing). JET provides Busy Context API to handle asynchronous REST calls in synchronous way.
I will describe how to apply Busy Context API in your JET application. Take a look into my sample app (JET + ADF BC REST) available on GitHub – JETCRUD. When you run sample app, go to Customers tab and navigate to edit screen. There you will find Save button, which is enabled:

Save button calls saveCustomer() JS function. JET Busy Context is established in this method, before making REST call. Busy Context is attached to Save button. If there are no busy states in the context, function isReady() returns true and we can register busy context. After busy context is registered – REST call can be made. If saveCustomer() JS function will be called again, before REST call is executed – isReady() will return false and no REST call will be made. When busy state is created, we update observable variable – which helps to change disabled property for the button: Read the complete article here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s