Package org.zkoss.web.portlet
Class Portlets
java.lang.Object
org.zkoss.web.portlet.Portlets
Utilities to handle portlet.
- Author:
- tomyeh
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intWhether to append params if both uri and params contain the same parameter.static final intWhether to ignore params if both uri and params contain the same parameter.static final intWhether to overwrite uri if both uri and params contain the same parameter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringgenerateURI(String uri, Map params, int mode) Generates URI by appending the parameters.static final javax.portlet.PortletRequestDispatchergetRequestDispatcher(javax.portlet.PortletContext ctx, String uri, Map params, int mode) Returns the request dispatch of the specified URI.static final URLgetResource(javax.portlet.PortletContext ctx, String uri) Returns the resource of the specified uri.static final InputStreamgetResourceAsStream(javax.portlet.PortletContext ctx, String uri) Returns the resource stream of the specified uri.static final voidinclude(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.
-
Field Details
-
OVERWRITE_URI
public static final int OVERWRITE_URIWhether to overwrite uri if both uri and params contain the same parameter. Used bygenerateURI(java.lang.String, java.util.Map, int)- See Also:
-
IGNORE_PARAM
public static final int IGNORE_PARAMWhether to ignore params if both uri and params contain the same parameter. Used bygenerateURI(java.lang.String, java.util.Map, int)- See Also:
-
APPEND_PARAM
public static final int APPEND_PARAMWhether 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:
-
-
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 ignoremode- one ofOVERWRITE_URI,IGNORE_PARAM, andAPPEND_PARAM. It defines how to handle if both uri and params contains the same parameter.- Throws:
IOExceptionjavax.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 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 URL getResource(javax.portlet.PortletContext ctx, String uri) throws MalformedURLException Returns the resource of the specified uri. Unlike PortletContext.getResource, it handles "~" likegetRequestDispatcher(javax.portlet.PortletContext, java.lang.String, java.util.Map, int)did.- Throws:
MalformedURLException
-
getResourceAsStream
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
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.
-