Package org.zkoss.web.portlet
Class Portlets
- java.lang.Object
-
- org.zkoss.web.portlet.Portlets
-
public class Portlets extends java.lang.ObjectUtilities to handle portlet.- Author:
- tomyeh
-
-
Field Summary
Fields Modifier and Type Field Description static intAPPEND_PARAMWhether to append params if both uri and params contain the same parameter.static intIGNORE_PARAMWhether to ignore params if both uri and params contain the same parameter.static intOVERWRITE_URIWhether to overwrite uri if both uri and params contain the same parameter.
-
Constructor Summary
Constructors Constructor Description Portlets()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgenerateURI(java.lang.String uri, java.util.Map params, int mode)Generates URI by appending the parameters.static javax.portlet.PortletRequestDispatchergetRequestDispatcher(javax.portlet.PortletContext ctx, java.lang.String uri, java.util.Map params, int mode)Returns the request dispatch of the specified URI.static java.net.URLgetResource(javax.portlet.PortletContext ctx, java.lang.String uri)Returns the resource of the specified uri.static java.io.InputStreamgetResourceAsStream(javax.portlet.PortletContext ctx, java.lang.String uri)Returns the resource stream of the specified uri.static voidinclude(javax.portlet.PortletContext ctx, javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, java.lang.String uri, java.util.Map params, int mode)Includes the resource at the specified URI.
-
-
-
Field Detail
-
OVERWRITE_URI
public static final int OVERWRITE_URI
Whether to overwrite uri if both uri and params contain the same parameter. Used bygenerateURI(java.lang.String, java.util.Map, int)- See Also:
- Constant Field Values
-
IGNORE_PARAM
public static final int IGNORE_PARAM
Whether to ignore params if both uri and params contain the same parameter. Used bygenerateURI(java.lang.String, java.util.Map, int)- See Also:
- Constant Field Values
-
APPEND_PARAM
public static final int APPEND_PARAM
Whether to append params if both uri and params contain the same parameter. In other words, they both appear as the final query string. Used bygenerateURI(java.lang.String, java.util.Map, int)- See Also:
- Constant Field Values
-
-
Method Detail
-
include
public static final void include(javax.portlet.PortletContext ctx, javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, java.lang.String uri, java.util.Map params, int mode) throws java.io.IOException, javax.portlet.PortletExceptionIncludes 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 ignoremode- one ofOVERWRITE_URI,IGNORE_PARAM, andAPPEND_PARAM. It defines how to handle if both uri and params contains the same parameter.- Throws:
java.io.IOExceptionjavax.portlet.PortletException
-
getRequestDispatcher
public static final javax.portlet.PortletRequestDispatcher getRequestDispatcher(javax.portlet.PortletContext ctx, java.lang.String uri, java.util.Map params, int mode) throws javax.portlet.PortletExceptionReturns 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 ignoremode- one ofOVERWRITE_URI,IGNORE_PARAM, andAPPEND_PARAM. It defines how to handle if both uri and params contains the same parameter.- Throws:
javax.portlet.PortletException
-
getResource
public static final java.net.URL getResource(javax.portlet.PortletContext ctx, java.lang.String uri) throws java.net.MalformedURLExceptionReturns the resource of the specified uri. Unlike PortletContext.getResource, it handles "~" likegetRequestDispatcher(javax.portlet.PortletContext, java.lang.String, java.util.Map, int)did.- Throws:
java.net.MalformedURLException
-
getResourceAsStream
public static final java.io.InputStream getResourceAsStream(javax.portlet.PortletContext ctx, java.lang.String uri)Returns the resource stream of the specified uri. Unlike PortletContext.getResource, it handles "~" likegetRequestDispatcher(javax.portlet.PortletContext, java.lang.String, java.util.Map, int)did.
-
generateURI
public static final java.lang.String generateURI(java.lang.String uri, java.util.Map params, int mode)Generates URI by appending the parameters.- Parameters:
params- the parameters to append to the query stringmode- one ofOVERWRITE_URI,IGNORE_PARAM, andAPPEND_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.
-
-