Versions Compared

Key

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

...

Code Block
titleIPortletServant.java
borderStylesolid
/**
 * The PortletServant interface is a uPortal wrapper around a JSR-168 portlet that implements
 * the Portlet Servant mode. It provides methods for delegating rendering and action processing
 * to the servant portlet, exchanging attribute values with the Client Portlet, to watch for it's completion and to get the results of the servant's
 * operation.
 */
public interface IPortletServant {

    /**
     * Returns the servant ID given by the portlet servant locator.
     * @return a <code>String</code> value
     */
    public String getId();
    
    /** Allows the Client Portlet to ascertain if the Servant has accomplished the requested task 
     *  (Note that the way which a certain task is requested is not specified by this interface; 
     *  normally it will be documented by a particular IPortletServant and require some particular 
     *  configuration paramaters used to initialize the servant)
     *  @return boolean value
     */    
    public boolean isComplete(PortletRequest request);
    
    public Object getServantData(PortletRequest request);

    public void setServantData(PortletRequest request,Object value);

    public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException;
    
    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException;
}

...

Code Block
titleServantUtil.java
borderStylesolid
/**
 * The utility class that provides a portlet with the servant-side methods methods. 
 * 
 * @author Michael Ivanov, mivanov at unicon.net
 * @version $Revision: 1.1 $
 *
 */
public final class ServantUtil {
    
    public static boolean isServantMode(PortletRequest request) {
        return (InternalServantUtil.getServantId(request)!=null);
    }
    
    public static boolean isServantMode(HttpServletRequest request) {
        return (InternalServantUtil.getServantId(request)!=null);
    }
    
    public static void setAttribute(PortletRequest request, Object value) {
        InternalServantUtil.setAttribute(InternalServantUtil.getServantId(request),request,value);
    }
    
    public static Object getAttribute(PortletRequest request) {
        return InternalServantUtil.getAttribute(InternalServantUtil.getServantId(request),request);
    }
    
    public static void setServantDone(PortletRequest request) {
       request.setAttribute(InternalServantUtil.getServantDoneKey(InternalServantUtil.getServantId(request)),"true");
    }
    
    private ServantUtil() {}
}

...