Class Portlets

java.lang.Object
org.zkoss.web.portlet.Portlets

public class Portlets extends Object
Utilities to handle portlet.
Author:
tomyeh
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Whether to append params if both uri and params contain the same parameter.
    static final int
    Whether to ignore params if both uri and params contain the same parameter.
    static final int
    Whether to overwrite uri if both uri and params contain the same parameter.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final String
    generateURI(String uri, Map params, int mode)
    Generates URI by appending the parameters.
    static final javax.portlet.PortletRequestDispatcher
    getRequestDispatcher(javax.portlet.PortletContext ctx, String uri, Map params, int mode)
    Returns the request dispatch of the specified URI.
    static final URL
    getResource(javax.portlet.PortletContext ctx, String uri)
    Returns the resource of the specified uri.
    static final InputStream
    getResourceAsStream(javax.portlet.PortletContext ctx, String uri)
    Returns the resource stream of the specified uri.
    static final void
    include(javax.portlet.PortletContext ctx, javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, String uri, Map params, int mode)
    Includes the resource at the specified URI.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Portlets

      public Portlets()
  • Method Details

    • include

      public static final void include(javax.portlet.PortletContext ctx, javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, String uri, Map params, int mode) throws IOException, javax.portlet.PortletException
      Includes the resource at the specified URI. It enhances RequestDispatcher to allow the inclusion with a parameter map -- actually converting parameters to a query string and appending it to uri.

      NOTE: don't include query parameters in uri.

      Parameters:
      uri - the URI to include. It is OK to relevant (without leading '/'). If starts with "/", the context path of request is assumed. To reference to foreign context, use "~ctx/" where ctx is the context path of the foreign context (without leading '/').
      params - the parameter map; null to ignore
      mode - one of OVERWRITE_URI, IGNORE_PARAM, and APPEND_PARAM. It defines how to handle if both uri and params contains the same parameter.
      Throws:
      IOException
      javax.portlet.PortletException
    • getRequestDispatcher

      public static final javax.portlet.PortletRequestDispatcher getRequestDispatcher(javax.portlet.PortletContext ctx, String uri, Map params, int mode) throws javax.portlet.PortletException
      Returns the request dispatch of the specified URI.
      Parameters:
      ctx - the context used to resolve a foreign context. It is required only if uri starts with "~".
      uri - the URI to include. It is OK to relevant (without leading '/'). If starts with "/", the context path of request is assumed. To reference to foreign context, use "~ctx/" where ctx is the context path of the foreign context (without leading '/').
      params - the parameter map; null to ignore
      mode - one of OVERWRITE_URI, IGNORE_PARAM, and APPEND_PARAM. It defines how to handle if both uri and params contains the same parameter.
      Throws:
      javax.portlet.PortletException
    • getResource

      public static final URL getResource(javax.portlet.PortletContext ctx, String uri) throws MalformedURLException
      Returns the resource of the specified uri. Unlike PortletContext.getResource, it handles "~" like getRequestDispatcher(javax.portlet.PortletContext, java.lang.String, java.util.Map, int) did.
      Throws:
      MalformedURLException
    • getResourceAsStream

      public static final InputStream getResourceAsStream(javax.portlet.PortletContext ctx, String uri)
      Returns the resource stream of the specified uri. Unlike PortletContext.getResource, it handles "~" like getRequestDispatcher(javax.portlet.PortletContext, java.lang.String, java.util.Map, int) did.
    • generateURI

      public static final String generateURI(String uri, Map params, int mode)
      Generates URI by appending the parameters.
      Parameters:
      params - the parameters to append to the query string
      mode - one of OVERWRITE_URI, IGNORE_PARAM, and APPEND_PARAM. It defines how to handle if both uri and params contains the same parameter. mode is used only if both uri contains query string and params is not empty.