|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.portlet.GenericPortlet
org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher
public class Jsr168Dispatcher
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>
Field Summary | |
---|---|
private Map<javax.portlet.PortletMode,ActionMapping> |
actionMap
|
private ActionMapper |
actionMapper
|
private Dispatcher |
dispatcherUtils
|
private ActionProxyFactory |
factory
|
private static Log |
LOG
|
private Map<javax.portlet.PortletMode,String> |
modeMap
|
private String |
portletNamespace
|
Fields inherited from interface org.apache.struts2.StrutsStatics |
---|
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_PORTLET_CONTEXT |
Fields inherited from interface org.apache.struts2.portlet.PortletActionConstants |
---|
ACTION_PARAM, DEFAULT_ACTION_FOR_MODE, DEFAULT_ACTION_NAME, ERROR_ACTION, EVENT_ACTION, EVENT_PHASE, MODE_NAMESPACE_MAP, MODE_PARAM, PHASE, PORTLET_CONFIG, PORTLET_NAMESPACE, RENDER_PHASE, REQUEST, RESPONSE |
Constructor Summary | |
---|---|
Jsr168Dispatcher()
|
Method Summary | |
---|---|
HashMap |
createContextMap(Map requestMap,
Map parameterMap,
Map sessionMap,
Map applicationMap,
javax.portlet.PortletRequest request,
javax.portlet.PortletResponse response,
javax.portlet.PortletConfig portletConfig,
Integer phase)
Merges all application and portlet attributes into a single HashMap to represent the entire Action context. |
void |
destroy()
|
protected ActionMapping |
getActionMapping(javax.portlet.PortletRequest request)
Gets the namespace of the action from the request. |
(package private) String |
getActionName(String actionPath)
Get the action name part of the action path. |
protected Map |
getApplicationMap()
Returns a Map of all application attributes. |
(package private) String |
getNamespace(String actionPath)
Get the namespace part of the action path. |
protected Map |
getParameterMap(javax.portlet.PortletRequest request)
Returns a Map of all request parameters. |
protected Map |
getRequestMap(javax.portlet.PortletRequest request)
Returns a Map of all request attributes. |
protected Map |
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 |
private void |
parseModeConfig(javax.portlet.PortletConfig portletConfig,
javax.portlet.PortletMode portletMode,
String nameSpaceParam,
String defaultActionParam)
Parse the mode to namespace mappings configured in 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. |
private boolean |
resetAction(javax.portlet.PortletRequest request)
Check to see if the action parameter is valid for the current portlet mode. |
private void |
resetActionContext()
Reset the action context. |
void |
serviceAction(javax.portlet.PortletRequest request,
javax.portlet.PortletResponse response,
ActionMapping mapping,
Map requestMap,
Map parameterMap,
Map sessionMap,
Map applicationMap,
String portletNamespace,
Integer phase)
Loads the action and executes it. |
void |
setActionMapper(ActionMapper actionMapper)
|
protected void |
setActionProxyFactory(ActionProxyFactory factory)
Convenience method to ease testing. |
Methods inherited from class javax.portlet.GenericPortlet |
---|
doDispatch, doEdit, doHelp, doView, getInitParameter, getInitParameterNames, getPortletConfig, getPortletContext, getPortletName, getResourceBundle, getTitle, init |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Log LOG
private ActionProxyFactory factory
private Map<javax.portlet.PortletMode,String> modeMap
private Map<javax.portlet.PortletMode,ActionMapping> actionMap
private String portletNamespace
private Dispatcher dispatcherUtils
private ActionMapper actionMapper
Constructor Detail |
---|
public Jsr168Dispatcher()
Method Detail |
---|
public void init(javax.portlet.PortletConfig cfg) throws javax.portlet.PortletException
init
in interface javax.portlet.Portlet
init
in class javax.portlet.GenericPortlet
javax.portlet.PortletException
private void parseModeConfig(javax.portlet.PortletConfig portletConfig, javax.portlet.PortletMode portletMode, String nameSpaceParam, String defaultActionParam)
portletConfig
- The PortletConfigportletMode
- The PortletModenameSpaceParam
- Name of the init parameter where the namespace for the mode
is configured.defaultActionParam
- Name of the init parameter where the default action to
execute for the mode is configured.public 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
javax.portlet.PortletException
IOException
Portlet.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
javax.portlet.PortletException
IOException
Portlet.render(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
private void resetActionContext()
public HashMap createContextMap(Map requestMap, Map parameterMap, Map sessionMap, Map applicationMap, javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, javax.portlet.PortletConfig portletConfig, Integer phase)
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.portletConfig
- the PortletConfig object.phase
- The portlet phase (render or action, see
PortletActionConstants
)
public void serviceAction(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, ActionMapping mapping, Map requestMap, Map parameterMap, Map sessionMap, Map applicationMap, String portletNamespace, Integer phase) throws javax.portlet.PortletException
request
- the HttpServletRequest object.response
- the HttpServletResponse object.mapping
- the action mapping.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
PortletActionConstants
)
javax.portlet.PortletException
protected Map getApplicationMap()
PortletActionContext
into an ApplicationMap
.
protected ActionMapping getActionMapping(javax.portlet.PortletRequest request)
view
, and edit mode is mapped to the namespace
edit
request
- the PortletRequest object.
String getNamespace(String actionPath)
actionPath
- Full path to action
String getActionName(String actionPath)
actionPath
- Full path to action
protected Map 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 getRequestMap(javax.portlet.PortletRequest request)
RequestMap
. Override this method to
customize how request attributes are mapped.
request
- the PortletRequest object.
protected Map 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
- private boolean resetAction(javax.portlet.PortletRequest request)
true
the default<Mode>Action
is used instead.
request
- The portlet request.
true
if the action should be reset.public void destroy()
destroy
in interface javax.portlet.Portlet
destroy
in class javax.portlet.GenericPortlet
public void setActionMapper(ActionMapper actionMapper)
actionMapper
- the actionMapper to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |