Application Class for wccApiSample

The Application class (com.tibco.wcc.wccApiSample.Application) provided with the wccApiSample application illustrates calling each of the server requests, as well as submitting the request, and handling the response from the server.

The Application class contains four sections specifically related to submitting server requests. They are labelled Section 1, 2, 3, and 4 in the file (wccApiSample\application\js\Application.js), and are described below:

Section 1

This section contains the functions that are called when a server request is initiated by clicking a button in the left pane of the wccApiSample application.

As an example, the following function is called when the Allocate Work Items button is clicked in the wccApiSample application:

classProto.execute_allocateWorkItems = function () {
   var requestId = "ApiSample.allocateWorkItems";
   var socketId = requestId;
   var arrayWorkItems = this.private_getWorkItems();
   var pane = this.getAppBlock().getDescendantOfName('blockEntity_allocateWorkItems');
   var txtResourceGuid = pane.getDescendantOfName('txtGuid').getValue();
   var request = com.tibco.wcc.base.Requests.allocateWorkItems(requestId,                   arrayWorkItems, txtResourceGuid);
   var oResponseXml = this.executeServerRequests(socketId, [request]);
   this.displayResponseXml(oResponseXml);

Most of the functions in Section 1 illustrate building the request object, then submitting the request with the executeServerRequests method.

Section 2

This section contains helper functions that the sample application uses to process the server request responses. Responses are in an XML format that is displayed in its entirety in the upper-right portion of the sample application. For some requests, the response XML is used to populate a more readable list of data in a General Interface Matrix control.

Section 3

This section contains helper functions that the sample application uses to populate complex input for some of the server requests. Valid input for some requests must come from the response of another request. The sample application displays some results in a list where items can be selected. In places where another server request can use that information as input, there is a button that moves the appropriate data about the selected items into the input. For instance, once you have a list of process templates, you can select one or more templates and add them to the input for retrieving process instances. The functions in this section perform that move.

Section 4

This section contains helper functions that the sample application uses to generate some of the more complex forms of input for the Server Requests. Some of the inputs are arrays of items. These functions build those arrays from user input controls.

You can use the functions in Sections 2-4 as a guide for handling user input data and request responses.