public class Jsr168Dispatcher extends javax.portlet.GenericPortlet implements StrutsStatics
Struts JSR-168 portlet dispatcher. Similar to the WW2 Servlet dispatcher, but adjusted to a portal environment. The portlet is configured through the portlet.xml descriptor. Examples and descriptions follow below:
Init parameters
Name | Description | Default value |
---|---|---|
portletNamespace | The namespace for the portlet in the xwork configuration. This namespace is prepended to all action lookups, and makes it possible to host multiple portlets in the same portlet application. If this parameter is set, the complete namespace will be /portletNamespace/modeNamespace/actionName | The default namespace |
viewNamespace | Base namespace in the xwork configuration for the view portlet mode | The default namespace |
editNamespace | Base namespace in the xwork configuration for the edit portlet mode | The default namespace |
helpNamespace | Base namespace in the xwork configuration for the help portlet mode | The default namespace |
defaultViewAction | Default action to invoke in the view portlet mode if no action is specified | default |
defaultEditAction | Default action to invoke in the edit portlet mode if no action is specified | default |
defaultHelpAction | Default action to invoke in the help portlet mode if no action is specified | default |
Example:
<init-param> <!-- The view mode namespace. Maps to a namespace in the xwork config file --> <name>viewNamespace</name> <value>/view</value> </init-param> <init-param> <!-- The default action to invoke in view mode --> <name>defaultViewAction</name> <value>index</value> </init-param> <init-param> <!-- The view mode namespace. Maps to a namespace in the xwork config file --> <name>editNamespace</name> <value>/edit</value> </init-param> <init-param> <!-- The default action to invoke in view mode --> <name>defaultEditAction</name> <value>index</value> </init-param> <init-param> <!-- The view mode namespace. Maps to a namespace in the xwork config file --> <name>helpNamespace</name> <value>/help</value> </init-param> <init-param> <!-- The default action to invoke in view mode --> <name>defaultHelpAction</name> <value>index</value> </init-param>
Modifier and Type | Field and Description |
---|---|
protected String |
portletNamespace |
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION, STRUTS_PORTLET_CONTEXT
Constructor and Description |
---|
Jsr168Dispatcher() |
Modifier and Type | Method and Description |
---|---|
HashMap<String,Object> |
createContextMap(Map<String,Object> requestMap,
Map<String,String[]> parameterMap,
Map<String,Object> sessionMap,
Map<String,Object> applicationMap,
javax.portlet.PortletRequest request,
javax.portlet.PortletResponse response,
javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
javax.servlet.ServletContext servletContext,
javax.portlet.PortletConfig portletConfig,
PortletPhase phase)
Merges all application and portlet attributes into a single
HashMap to represent the entire Action context.
|
protected PortletServletResponse |
createPortletServletResponse(javax.portlet.PortletResponse response)
Method to create a PortletServletResponse matching the used Portlet API, to be overridden for JSR286 Dispatcher.
|
void |
destroy() |
protected ActionMapping |
getActionMapping(javax.portlet.PortletRequest portletRequest,
javax.servlet.http.HttpServletRequest servletRequest)
Gets the namespace of the action from the request.
|
protected Map<String,Object> |
getApplicationMap()
Returns a Map of all application attributes.
|
protected String |
getDefaultActionPath(javax.portlet.PortletRequest portletRequest) |
protected Locale |
getLocale(javax.portlet.PortletRequest request) |
protected Map<String,String[]> |
getParameterMap(javax.portlet.PortletRequest request)
Returns a Map of all request parameters.
|
protected Map<String,Object> |
getRequestMap(javax.portlet.PortletRequest request)
Returns a Map of all request attributes.
|
protected Map<String,Object> |
getSessionMap(javax.portlet.PortletRequest request)
Returns a Map of all session attributes.
|
void |
init(javax.portlet.PortletConfig cfg)
Initialize the portlet with the init parameters from portlet.xml
|
void |
processAction(javax.portlet.ActionRequest request,
javax.portlet.ActionResponse response)
Service an action from the event phase.
|
void |
render(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response)
Service an action from the render phase.
|
void |
serviceAction(javax.portlet.PortletRequest request,
javax.portlet.PortletResponse response,
Map<String,Object> requestMap,
Map<String,String[]> parameterMap,
Map<String,Object> sessionMap,
Map<String,Object> applicationMap,
String portletNamespace,
PortletPhase phase)
Loads the action and executes it.
|
void |
setActionMapper(ActionMapper actionMapper) |
protected void |
setActionProxyFactory(ActionProxyFactory factory)
Convenience method to ease testing.
|
doDispatch, doEdit, doHeaders, doHelp, doView, getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, processEvent, serveResource
protected String portletNamespace
public void init(javax.portlet.PortletConfig cfg) throws javax.portlet.PortletException
init
in interface javax.portlet.Portlet
init
in class javax.portlet.GenericPortlet
cfg
- portlet configurationjavax.portlet.PortletException
- in case of errorspublic void processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response) throws javax.portlet.PortletException, IOException
processAction
in interface javax.portlet.Portlet
processAction
in class javax.portlet.GenericPortlet
request
- action requestresponse
- action responsejavax.portlet.PortletException
- in case of errorsIOException
- in case of IO errorsPortlet.processAction(javax.portlet.ActionRequest,
javax.portlet.ActionResponse)
public void render(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response) throws javax.portlet.PortletException, IOException
render
in interface javax.portlet.Portlet
render
in class javax.portlet.GenericPortlet
request
- render requestresponse
- render responsejavax.portlet.PortletException
- in case of errorsIOException
- in case of IO errorsPortlet.render(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
public HashMap<String,Object> createContextMap(Map<String,Object> requestMap, Map<String,String[]> parameterMap, Map<String,Object> sessionMap, Map<String,Object> applicationMap, javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, javax.servlet.ServletContext servletContext, javax.portlet.PortletConfig portletConfig, PortletPhase phase) throws IOException
requestMap
- a Map of all request attributes.parameterMap
- a Map of all request parameters.sessionMap
- a Map of all session attributes.applicationMap
- a Map of all servlet context attributes.request
- the PortletRequest object.response
- the PortletResponse object.servletRequest
- the HttpServletRequest object.servletResponse
- the HttpServletResponse object.servletContext
- the ServletContext object.portletConfig
- the PortletConfig object.phase
- The portlet phase (render or action, see
PortletConstants
)IOException
- in case of IO errorsprotected Locale getLocale(javax.portlet.PortletRequest request)
public void serviceAction(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, Map<String,Object> requestMap, Map<String,String[]> parameterMap, Map<String,Object> sessionMap, Map<String,Object> applicationMap, String portletNamespace, PortletPhase phase) throws javax.portlet.PortletException
request
- the HttpServletRequest object.response
- the HttpServletResponse object.requestMap
- a Map of request attributes.parameterMap
- a Map of request parameters.sessionMap
- a Map of all session attributes.applicationMap
- a Map of all application attributes.portletNamespace
- the namespace or context of the action.phase
- The portlet phase (render or action, see PortletConstants
)javax.portlet.PortletException
- in case of errorsprotected Map<String,Object> getApplicationMap()
PortletActionContext
into an ApplicationMap
.protected ActionMapping getActionMapping(javax.portlet.PortletRequest portletRequest, javax.servlet.http.HttpServletRequest servletRequest)
view
, and edit mode is mapped to the namespace
edit
portletRequest
- the PortletRequest object.servletRequest
- the ServletRequest to useprotected String getDefaultActionPath(javax.portlet.PortletRequest portletRequest)
protected Map<String,String[]> getParameterMap(javax.portlet.PortletRequest request) throws IOException
PortletRequest.getParameterMap()
.request
- the PortletRequest object.IOException
- if an exception occurs while retrieving the parameter
map.protected Map<String,Object> getRequestMap(javax.portlet.PortletRequest request)
RequestMap
. Override this method to
customize how request attributes are mapped.request
- the PortletRequest object.protected Map<String,Object> getSessionMap(javax.portlet.PortletRequest request)
SessionMap
. Override this method to
customize how session attributes are mapped.request
- the PortletRequest object.protected void setActionProxyFactory(ActionProxyFactory factory)
factory
- action proxy factorypublic void destroy()
destroy
in interface javax.portlet.Portlet
destroy
in class javax.portlet.GenericPortlet
public void setActionMapper(ActionMapper actionMapper)
actionMapper
- the actionMapper to setprotected PortletServletResponse createPortletServletResponse(javax.portlet.PortletResponse response)
response
- The Response used for building the wrapper.Copyright © 2000–2020 Apache Software Foundation. All rights reserved.