This How to Guide deals with the following topics:
- Being able use SICF handler classes which also have access to BSP controller classes
- Not having to create a new SICF service, each time there is demand for bypassing the BSP hierarchy
Generic crm_callback Service and its Methods
A new generic SICF service "crm_callback" was created.
To access this service, one can create a URL which points to that service and add two parameters, one including the name of one's custom handler class and one including the controller id. The latter is optional.
For convenience the method CL_CRM_WEB_UTILITY=>CREATE_SERVICE_URL has been created, which passes back a URL which
- points to our generic service with the controller id and the handler class
- is in the same session (something which has to be insured if one wants to access a BSP controller)
The method has the following important parameters:
- IV_HANDLER_CLASS_NAME Name of handler class
- IV_CONTROLLER_ID Controller ID
- IV_QUERY Additional parameters you want to pass to the backend
For further convenience CL_CRM_WEB_UTILITY=> CREATE_SERVICE_SCRIPT goes a step further and passes back a JS snippet which if invoked creates an AJAX request (using the thtmlb AJAX library) to the generic service, so it immediately carries out the request to the backend after invoking. Apart from the parameters of the CREATE_SERVICE_URL it has the additional optional important parameter IV_JS_CALLBACK_FUNCTION name of a JS function that is called when the response is retrieved by the AJAX object
The Handler Class
You can define your own handler class. All it requires is that interface IF_CRM_WEB_CALLBACK Is implemented. This interface comes with one method: HANDLE_REQUEST HANDLE_REQUEST gets the server object (IR_SERVER) passed, thus one has access to the request and response object just like one has in an SICF service handler. On top of this though, it also gets the instance of the controller (IR_CONTROLLER) which belongs to the controller id specified in the URL.
Create a Script on a view that points to the view's controller and attach this script to a button:
Create a Script on a view that points to the view's controller and attach this script to a button + attach a callback JS function:
Example of the whole process
In CRM_THTMLB_COMP/formConfig there is a new button underneath the form.
The view formConfig.htm includes the above coding. When one hits the button, an AJAX request is invoked and the SICF service is called. The service in turn calls demo handler class CL_THTMLB_CALLBACK_DEMO or rather its methods HANDLE_REQUEST. In this the configuration XML is retrieved from the BSP controller's config object and put into an HTTP response. This response is used by the demo response callback JS function thtmlbCompCallbackTest which just puts the XML of the response into an alerted message.