Client library enablement for Struts

The Struts Component Service Action is a Struts Action implementation class that can be used to invoke a component service from a traditional Web application.The Struts Component Service Action is a subclass of com.ibm.commerce.struts.BaseAction in WebSphere Commerce Versions 9.0.0.x, and com.ibm.commerce.struts.v2.BaseAction in Versions 9.0.1.0+. This service action overrides the invokeService() method. The new implementation of invokeService() passes the input parameters map to a configured client library method which will perform a service and return an output parameter map.

After the request has been completed, the default behavior of the service action is to cause a redirect to the URL specified by either the redirecturl or URL input parameter. This is done by adding RedirectView as the value of an output parameter named viewTaskName before returning the output map at the end of the invokeService() method. This causes the base action implementation to invoke the RedirectView command.

The Struts Component Service Action implementation has the following class name:

A new Struts Action implementation provides access to the Web-friendly methods of service modules. IBM recommends that a new Struts configuration file is created for each service module (struts-config- myservicemodule.xml).


Struts client service plug-in

The Struts configuration file must define a component plug-in with the service module client facade and an ID to refer to the service module. Action mapping parameters are defined in the form id.clientmethod, where id is the service module ID and client method is a Web-friendly method contained in the service module client facade. The following example provides an example of the component plug-in configuration and an action mapping parameter definition:

The parameter attribute defines the client library that is to be used. The clientMethod parameter defines the client library method.


Client library enablement for AJAX

The Struts Ajax Component Service Action is a Struts Action implementation class that can be used to invoke a WebSphere Commerce service using an Ajax style browser request. All URL-enabled services are enabled for AJAX support and just need to be configured.

The Struts Ajax Component Service Action is a subclass of com.ibm.commerce.struts.BaseAction and overrides the invokeService method. The new implementation of invokeService passes the input parameters map to a configured client library method which calls a service and returns an output parameter map.

Once the request is complete, it is forwarded to a JSP file that composes the service response. The service response JSP file creates a JSON object out of the values found in the response Map.

The Struts Ajax Component Service Action has the following class name:

A Struts action that uses the Ajax Component Service Action implementation is configured in struts-config.xml as shown in the following XML sample:

The parameter attribute defines the client library that is to be used. The clientMethod parameter defines the client library method.


Related concepts
Client library for WebSphere Commerce services
Web enablement for the client library


Related tasks
Creating the client library
Extending the client library


Related reference
WebSphere Commerce foundation tag library