org.xwiki.portlet
Class DispatchPortlet

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by org.xwiki.portlet.DispatchPortlet
All Implemented Interfaces:
javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet
Direct Known Subclasses:
XWikiDispatchPortlet

public class DispatchPortlet
extends javax.portlet.GenericPortlet

Dispatches portlet requests coming from a JSR286 compatible portal to the URL provided either in the PARAMETER_DISPATCH_URL request parameter on in the DispatchURLFactory.PARAMETER_DISPATCH_URL URL parameter. The dispatch target must be on the same context path as the dispatch portlet.

Version:
$Id: 8c523b2143288a45bea6d486a0d757e0c4b8eacd $

Field Summary
static String ATTRIBUTE_DISPATCHED
          The request attribute used to mark the request as dispatched.
static String ATTRIBUTE_REDIRECT_URL
          The request attribute used to pass the redirect URL to the dispatch filter in order to adjust the dispatched request accordingly.
static String ATTRIBUTE_RESPONSE_DATA
          The data of a dispatched response.
static String ATTRIBUTE_RESPONSE_DATA_MAP
          The map of response data, stored on the session.
static String PARAMETER_DISPATCH_URL
          The name of the portlet request parameter holding the URL to dispatch the request to.
static String PARAMETER_DISPATCHED_RESPONSE_KEY
          The key to access the data of a dispatched response from the session.
static String PREFERENCE_DEFAULT_DISPATCH_URL
          The name of the preference holding the default dispatch URL, i.e.
static String PREFERENCE_EDIT_URL
          The name of the preference holding the edit URL, i.e.
static String PREFERENCE_TITLE
          The name of the preference that controls the title of the portlet.
 
Constructor Summary
DispatchPortlet()
           
 
Method Summary
protected  void doEdit(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
           
protected  void doView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
           
protected  String getDefaultDispatchURL(javax.portlet.PortletPreferences preferences)
           
protected  String getTitle(javax.portlet.RenderRequest request)
           
 void processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
           
protected  void processEdit(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Processes the edit action.
protected  void processView(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Processed the view action.
 void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
           
 
Methods inherited from class javax.portlet.GenericPortlet
destroy, doDispatch, doHeaders, doHelp, getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, init, init, processEvent, render
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_DISPATCH_URL

public static final String PARAMETER_DISPATCH_URL
The name of the portlet request parameter holding the URL to dispatch the request to. Unlike DispatchURLFactory.PARAMETER_DISPATCH_URL which is a URL parameter set on the server side, this is a request parameter received from the client side as part of the post body data. When determining the dispatch URL, if present, this request parameter overwrites the URL parameter.

See Also:
DispatchURLFactory.PARAMETER_DISPATCH_URL, Constant Field Values

PARAMETER_DISPATCHED_RESPONSE_KEY

public static final String PARAMETER_DISPATCHED_RESPONSE_KEY
The key to access the data of a dispatched response from the session.

See Also:
Constant Field Values

PREFERENCE_DEFAULT_DISPATCH_URL

public static final String PREFERENCE_DEFAULT_DISPATCH_URL
The name of the preference holding the default dispatch URL, i.e. the URL used to dispatch the request when there's no dispatch URL parameter specified on the request.

See Also:
Constant Field Values

PREFERENCE_EDIT_URL

public static final String PREFERENCE_EDIT_URL
The name of the preference holding the edit URL, i.e. the URL where the edit request is dispatched to. This URL must be relative to the context path where the portlet is running.

See Also:
Constant Field Values

PREFERENCE_TITLE

public static final String PREFERENCE_TITLE
The name of the preference that controls the title of the portlet.

See Also:
Constant Field Values

ATTRIBUTE_RESPONSE_DATA_MAP

public static final String ATTRIBUTE_RESPONSE_DATA_MAP
The map of response data, stored on the session.

See Also:
Constant Field Values

ATTRIBUTE_RESPONSE_DATA

public static final String ATTRIBUTE_RESPONSE_DATA
The data of a dispatched response.

See Also:
Constant Field Values

ATTRIBUTE_REDIRECT_URL

public static final String ATTRIBUTE_REDIRECT_URL
The request attribute used to pass the redirect URL to the dispatch filter in order to adjust the dispatched request accordingly. We transform redirects into dispatches because redirects are not allowed during render request and we can't create action URLs during action request.

Forwarding the request multiple times is not enough because some portlet containers send all the requests to the same dispatch target, the target of the first dispatch.

See Also:
DispatchURLFactory.PARAMETER_DISPATCH_URL, Constant Field Values

ATTRIBUTE_DISPATCHED

public static final String ATTRIBUTE_DISPATCHED
The request attribute used to mark the request as dispatched. The dispatch filter is a servlet filter and thus can be called before this portlet. We mark the request as dispatched before forwarding it so that the dispatch filter knows when to process the request.

See Also:
Constant Field Values
Constructor Detail

DispatchPortlet

public DispatchPortlet()
Method Detail

processAction

public void processAction(javax.portlet.ActionRequest request,
                          javax.portlet.ActionResponse response)
                   throws javax.portlet.PortletException,
                          IOException
Specified by:
processAction in interface javax.portlet.Portlet
Overrides:
processAction in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

processView

protected void processView(javax.portlet.ActionRequest request,
                           javax.portlet.ActionResponse response)
                    throws javax.portlet.PortletException,
                           IOException
Processed the view action.

Parameters:
request - the action request
response - the action response
Throws:
IOException - if writing the response fails
javax.portlet.PortletException - if processing the action fails

processEdit

protected void processEdit(javax.portlet.ActionRequest request,
                           javax.portlet.ActionResponse response)
                    throws javax.portlet.PortletException,
                           IOException
Processes the edit action.

Parameters:
request - the action request
response - the action response
Throws:
javax.portlet.PortletException - if processing the edit form fails
IOException - if saving the portlet preferences fails

getTitle

protected String getTitle(javax.portlet.RenderRequest request)
Overrides:
getTitle in class javax.portlet.GenericPortlet

doView

protected void doView(javax.portlet.RenderRequest request,
                      javax.portlet.RenderResponse response)
               throws javax.portlet.PortletException,
                      IOException
Overrides:
doView in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

doEdit

protected void doEdit(javax.portlet.RenderRequest request,
                      javax.portlet.RenderResponse response)
               throws javax.portlet.PortletException,
                      IOException
Overrides:
doEdit in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

serveResource

public void serveResource(javax.portlet.ResourceRequest request,
                          javax.portlet.ResourceResponse response)
                   throws javax.portlet.PortletException,
                          IOException
Specified by:
serveResource in interface javax.portlet.ResourceServingPortlet
Overrides:
serveResource in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

getDefaultDispatchURL

protected String getDefaultDispatchURL(javax.portlet.PortletPreferences preferences)
Parameters:
preferences - the portlet preferences to take the default dispatch URL from
Returns:
the URL used to dispatch the request when there's no dispatch URL parameter specified on the request


Copyright © 2004-2013 XWiki. All Rights Reserved.