Tag: declareService

The declareService tag adds client-side support for invoking a service request. The ID is used to register the specified service so it can be invoked with the wc.service.invoke(serviceId, parameters) function. The parameters parameter is an object map that will be passed as parameters to the service URL.

Tag Information
Tag File /META-INF/tags/wcf/DeclareService.tag
Body Content empty
Display Name Declare Service

Attributes
Name Required Type Description
id true String The service ID.
actionId true String The action identifier used to uniquely identify the action performed by this service.
url true String The URL to process this service.
formId false String The element ID of the form that is to be submitted to this service.
validateParametersScript false jspFragment JavaScript that validates the parameters that are being passed to this request. This script must be composed by a developer. The script uses the local variable parameters which is the Object map of parameters that were passed to the service. The script can also update a local variable called valid to false to indicate that the request must be stopped. If this attribute is not specified then the parameters are always considered to be valid.
validateFormScript false jspFragment JavaScript that validates the form specified by the formId. This script must be composed by a developer. The script uses the local variable formNode which is the form node extracted from the document. The script can also update a local variable called valid to false to indicate that the request must be stopped. If this attribute is not specified, then the form is always considered to be valid.
successTestScript false jspFragment JavaScript that examines the service response object to determine if the request was successful or not. The script makes use of the local variable serviceResponse which is the service response object. The script must also update a local variable called success to false to indicate that the request was not successful. This result determines if the success handler or the failure handler is invoked. If this attribute is not specified, then the service response Object will be tested to see if there is a property called errorCode. If the errorCode property exists, then the service request is treated as a failed request.
successHandlerScript false jspFragment JavaScript that is run after the successful invocation of the service request. The script can make use of the local variable serviceResponse which is an Object that contains the service response map.
failureHandlerScript false jspFragment JavaScript that is run after a failed invocation of the service request. The script can make use of the local variable serviceResponse which is an Object that contains the service response map.

 

Example

The following example declares a service called AjaxDeleteOrderItem that can be used to delete an order item.

<wcf:declareService id="AjaxDeleteOrderItem" actionId="
AjaxDeleteOrderItem" url="AjaxDeleteOrderItem">
</wcf:declareService>


Related Reference


WebSphere Commerce foundation tag library