Prior to Open UI you could only call workflows in asynchronous mode. Well technically it was possible to call a business service asynchronously by wrapping it in a workflow. With Open UI Oracle has provided us with a way to call Business Service, Business Component Methods, Applet Methods and of-course workflows asynchronously. The icing on the cake is ability to associate a call back method that will be executed once the request is complete.
Excited???? Now imagine that you have implement following requirement.
You have to implement a search functionality with following features:
- User should be able to click search image to initiate search.
- While the search is happening page should get a nice Web 2.0 style “Please Wait” message.
- UI should be blocked so that user cannot do anything (except for closing the browser window) funny while waiting for search to complete.
- Once the search is complete everything should return to normal and UI should be unblocked.
There are three parts to this requirement:
- To be able to search by clicking on an image
- Block the UI Show a “Please Wait” message.
- Perform Search, Unblock UI and remove the message.
In this post I will only be discuss third part that involves invoking search functionality asynchronously. So, what are we waiting for let’s get started!!
Siebel has introduced another parameter in BS and BC method calls, named AI (Additional Input) that can run an AJAX calls. You define AI as JavaScript Object and it have following arguments
- async : True or False. If True then method the call will be made asynchronously
- cb: Define a callback function that should be called once the method is complete
- scope: the value should be “this” (without quotes)
- errcb: Have a error callback function if AJAX call fails
- opdecode: Decode or not decode the AJAX call
- mask: Mask the screen or not
- selfbusy: Display busy cursor or not
Now back to the 3rd part of the requirement. On click of image a method define applet to perform search should be called in async mode using AI parameter.
Below is how would define the AI object
var configObj = {}; //define an empty object configObj.async = true; //this is key argument. if set to false then method will be called in usual way. configObj.scope = this; //always set as "this" config.cb = function(){ //method to execute as callback function. //write any code here that you would like to execute //after the call is complete }
To call method in Physical Renderer following code is used to invoke the method
var inPS= SiebelApp.S_App.NewPropertySet(); this.GetPM().ExecuteMethod("InvokeMethod","ExecuteSearch", inPS, configObj);
To call method in Presentation Model following code will be used to invoke the method:
var inPS= SiebelApp.S_App.NewPropertySet(); this.ExecuteMethod("InvokeMethod","ExecuteSearch", inPS, configObj);
In next post we will discuss blocking the UI part and finally the how the whole solution works.
Stay tuned!!!