Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The typical client-servant interaction from the client's point of view is shown below. Every time when the portlet's processAction() or render() is called the client has to get the reference to the IPortletServantLocator instance and , then call locate() to return the instance of the IPortletServant and delegate the request processing to the servant:

Code Block
titleTestServantPortlet.java
borderStylesolid
public class TestServantPortlet extends GenericPortlet {
    
/**
 * The internal method that returns the IPortletServant instance.
 */
private IPortletServant getPortletServant(String servantFname, PortletRequest request) {
    IPortletServantLocator servantLocator = ServantLocatorAccessor.getPortletServantLocator(getPortletContext());
    IPortletServant servant = servantLocator.locate(servantFname,request);
    return servant;
}
    
/**
 *  The implemenation of GenericPortlet's processAction() with delegating the action request processing to the servant.
 */
public void processAction(ActionRequest req, ActionResponse res) throws PortletException, IOException {
    
            // Get the servant functional name
            String servantFname = ...
            if ( servantFname != null ) {
               IPortletServant servant = getPortletServant(servantFname,req);
               servant.processAction(req,res);
               if ( servant.isComplete(req) ) {
                  // Get result when the servant is done
                  Object result = servant.getServantData(req);
                  ...
               }
            } 
}

...

}

...