org.apache.wicket.protocol.http.portlet
Class WicketPortlet

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by org.apache.wicket.protocol.http.portlet.WicketPortlet
All Implemented Interfaces:
javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet
Direct Known Subclasses:
WicketExamplesMenuPortlet

public class WicketPortlet
extends javax.portlet.GenericPortlet

Adapter between the Portlet world requests and the internal Wicket engine. I.e. simulates the web/servlet environment for Wicket, while it's actually running as a Portlet.

It receives a portlet request and dispatches to a a Wicket filter; wrapping the servlet context, request and response objects; intercepts response writing (especially urls and redirects) and rewrites and adapts the output to accommodate the portlet requirements.

The WicketPortlet is configured (using an initParameter) against a specific filter path, e.g. Wicket WebApplication. The WicketPortlet maintains a parameter for the current Wicket page URL being requested as a URL parameter, based against the filter path (e.g. fully qualified to the context path). When a request (action, render or direct resource/ajax call) is received by the WicketPortlet, it dispatches it to Wicket core as a filter request using the provided Wicket page URL parameter.

Author:
Ate Douma
See Also:
WICKET_URL_PORTLET_PARAMETER, WicketFilter

Field Summary
static String CONFIG_PARAM_PREFIX
          FIXME javadoc
static String PARAM_ACTION_PAGE
          Name of portlet init parameter for Action page
static String PARAM_CUSTOM_PAGE
          Name of portlet init parameter for Custom page
static String PARAM_EDIT_PAGE
          Name of portlet init parameter for Edit page
static String PARAM_HELP_PAGE
          Name of portlet init parameter for Edit page
static String PARAM_VIEW_PAGE
          Name of portlet init parameter for View page
static String RESPONSE_STATE_ATTR
          Marker used as key for the WicketResponseState object stored as a request attribute.
static String WICKET_FILTER_PATH
          FIXME javadoc
static String WICKET_FILTER_PATH_PARAM
          FIXME javadoc
static String WICKET_FILTER_QUERY
          FIXME javadoc
static String WICKET_PORTLET_PROPERTIES
          FIXME javadoc
static String WICKET_URL_PORTLET_PARAMETER
          FIXME javadoc
static String WICKET_URL_PORTLET_PARAMETER_ATTR
          FIXME javadoc
 
Constructor Summary
WicketPortlet()
           
 
Method Summary
protected  String buildWicketFilterPath(String filterPath)
           
protected  String buildWicketFilterQuery(String wicketFilterPath)
           
 void destroy()
           
protected  void doCustom(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
          Delegates to #processRequest(PortletRequest, PortletResponse, String, String).
protected  void doEdit(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
          Delegates to #processRequest(PortletRequest, PortletResponse, String, String).
protected  void doHelp(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
          Delegates to #processRequest(PortletRequest, PortletResponse, String, String).
protected  void doView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
          Delegates to #processRequest(PortletRequest, PortletResponse, String, String).
protected  String fixWicketUrl(String url, String wicketFilterPath, String wicketFilterQuery)
          FIXME javadoc
protected  String getDefaultPage(String pageType)
           
protected  String getWicketConfigParameter(javax.portlet.PortletRequest request, String paramName, String defaultValue)
          FIXME javadoc - definitely needs explanation - why is no lookup attempted?
protected  String getWicketFilterPath()
           
protected  Properties getWicketPortletProperties(Properties properties)
          Loads the Wicket Portlet properties file off the class path.
protected  String getWicketURL(javax.portlet.PortletRequest request, String pageType, String defaultPage)
          Retrieves the Wicket URL from the request object as a request parameter, or if none exists returns the default URL.
protected  String getWicketUrlPortletParameter(javax.portlet.PortletRequest request)
           
 void init(javax.portlet.PortletConfig config)
           
 void processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Delegates to #processRequest(PortletRequest, PortletResponse, String, String).
protected  void processActionResponseState(String wicketURL, String wicketFilterPath, String wicketFilterQuery, javax.portlet.PortletRequest request, javax.portlet.ActionResponse response, WicketResponseState responseState)
          Handles redirects set from processing the action.
protected  void processRequest(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, String pageType)
          Consumes and processes all portlet requests.
 void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
          Delegates to #processRequest(PortletRequest, PortletResponse, String, String).
protected  void validateDefaultPages(Map defaultPages, String wicketFilterPath, String wicketFilterQuery)
          FIXME javadoc
 
Methods inherited from class javax.portlet.GenericPortlet
doDispatch, doHeaders, getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, processEvent, render
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WICKET_URL_PORTLET_PARAMETER

public static final String WICKET_URL_PORTLET_PARAMETER
FIXME javadoc

The prefix for the parameter name for storing Wicket URLs.

The actual Wicket URLs generated by Wicket are passed around in portal URLs, encoded by the portal (as a URL parameter of this name). The Wicket URL is later decoded on subsequent requests, from the portal URL, so that we know where to route the request, once it's passed out of the 'portal' realm and into the 'Wicket' realm.

This is also used in generating links by PortletRequestContext in generating links, as the links have to be portal encoded links, but must also still contain the original wicket url for use by Wicket (e.g. PortletRequestContext.encodeActionURL(java.lang.CharSequence)).

The default/buildin name of the parameter which stores the name of the wicket url is stored under WICKET_URL_PORTLET_PARAMETER_ATTR. It will be stored suffixed with the current portlet mode (e.g. view), so that render requests now what mode to render.

See Also:
PortletRequestContext, WICKET_URL_PORTLET_PARAMETER_ATTR, Constant Field Values

WICKET_URL_PORTLET_PARAMETER_ATTR

public static final String WICKET_URL_PORTLET_PARAMETER_ATTR
FIXME javadoc

The attribute name (key) to store the Wicket URL parameter name under.

See Also:
WICKET_URL_PORTLET_PARAMETER, getWicketURL(javax.portlet.PortletRequest, java.lang.String, java.lang.String)

WICKET_FILTER_PATH_PARAM

public static final String WICKET_FILTER_PATH_PARAM
FIXME javadoc

See Also:
Constant Field Values

CONFIG_PARAM_PREFIX

public static final String CONFIG_PARAM_PREFIX
FIXME javadoc


RESPONSE_STATE_ATTR

public static final String RESPONSE_STATE_ATTR
Marker used as key for the WicketResponseState object stored as a request attribute.


WICKET_PORTLET_PROPERTIES

public static final String WICKET_PORTLET_PROPERTIES
FIXME javadoc


WICKET_FILTER_PATH

public static final String WICKET_FILTER_PATH
FIXME javadoc


WICKET_FILTER_QUERY

public static final String WICKET_FILTER_QUERY
FIXME javadoc


PARAM_ACTION_PAGE

public static final String PARAM_ACTION_PAGE
Name of portlet init parameter for Action page

See Also:
Constant Field Values

PARAM_CUSTOM_PAGE

public static final String PARAM_CUSTOM_PAGE
Name of portlet init parameter for Custom page

See Also:
Constant Field Values

PARAM_EDIT_PAGE

public static final String PARAM_EDIT_PAGE
Name of portlet init parameter for Edit page

See Also:
Constant Field Values

PARAM_HELP_PAGE

public static final String PARAM_HELP_PAGE
Name of portlet init parameter for Edit page

See Also:
Constant Field Values

PARAM_VIEW_PAGE

public static final String PARAM_VIEW_PAGE
Name of portlet init parameter for View page

See Also:
Constant Field Values
Constructor Detail

WicketPortlet

public WicketPortlet()
Method Detail

init

public void init(javax.portlet.PortletConfig config)
          throws javax.portlet.PortletException
Specified by:
init in interface javax.portlet.Portlet
Overrides:
init in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException

destroy

public void destroy()
Specified by:
destroy in interface javax.portlet.Portlet
Overrides:
destroy in class javax.portlet.GenericPortlet

getDefaultPage

protected String getDefaultPage(String pageType)
Parameters:
pageType - the mode of the portlet page, e.g. VIEW, EDIT etc...
Returns:
the default page name for the given pate type.

buildWicketFilterPath

protected String buildWicketFilterPath(String filterPath)

buildWicketFilterQuery

protected String buildWicketFilterQuery(String wicketFilterPath)

fixWicketUrl

protected String fixWicketUrl(String url,
                              String wicketFilterPath,
                              String wicketFilterQuery)
FIXME javadoc

Corrects the incoming URL if the old home page style, or if it's missing the filter path prefix.

Parameters:
url - the URL to fix
wicketFilterPath -
wicketFilterQuery -
Returns:
the corrected URL

validateDefaultPages

protected void validateDefaultPages(Map defaultPages,
                                    String wicketFilterPath,
                                    String wicketFilterQuery)
FIXME javadoc

Registers the default pages and their URLs for the different PortletModes. Also corrects and slightly incorrect URLs (see fixWicketUrl(String, String, String)).

If no specific page was specified for a given portlet mode (VIEW, EDIT etc) then the page for that mode is set to be the same page as that of the VIEW mode.

Parameters:
defaultPages -
wicketFilterPath -
wicketFilterQuery -
See Also:
PortletMode, fixWicketUrl(String, String, String)

getWicketPortletProperties

protected Properties getWicketPortletProperties(Properties properties)
                                         throws javax.portlet.PortletException
Loads the Wicket Portlet properties file off the class path. FIXME javadoc - check properties

Parameters:
properties - appends the portlet properties to
Returns:
Wicket portlet properties. Returns an empty or unchanged properties object if Wicket Portlet properties could not be found
Throws:
javax.portlet.PortletException - if loading the properties fails

getWicketConfigParameter

protected String getWicketConfigParameter(javax.portlet.PortletRequest request,
                                          String paramName,
                                          String defaultValue)
FIXME javadoc - definitely needs explanation - why is no lookup attempted?

Parameters:
request -
paramName -
defaultValue -
Returns:

getWicketUrlPortletParameter

protected String getWicketUrlPortletParameter(javax.portlet.PortletRequest request)
Parameters:
request -
Returns:
The prefix for the parameter name for storing Wicket URLs.
See Also:
WICKET_URL_PORTLET_PARAMETER

getWicketFilterPath

protected String getWicketFilterPath()

getWicketURL

protected String getWicketURL(javax.portlet.PortletRequest request,
                              String pageType,
                              String defaultPage)
Retrieves the Wicket URL from the request object as a request parameter, or if none exists returns the default URL. The name of the request parameter is stored as a request attribute.

This url is then used to pass on to the matching WicketFilter to process, by way of RequestDispatcher via the filters context path.

A "parameter" is a form field name/value pair passed from the HTML side of the world. Its value is a String.

An "attribute" is a Java object name/value pair passed only through the internal JavaServer processes. (I.e. it can come from a JSP or servlet but not an HTML page.) Its value is an Object.

Parameters:
request -
pageType -
defaultPage - url of the default page
Returns:
the Wicket URL from within the specified request
See Also:
PortletRequestContext.getLastEncodedPath()

doView

protected void doView(javax.portlet.RenderRequest request,
                      javax.portlet.RenderResponse response)
               throws javax.portlet.PortletException,
                      IOException
Delegates to #processRequest(PortletRequest, PortletResponse, String, String).

Overrides:
doView in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException
See Also:
#processRequest(PortletRequest, PortletResponse, String, String)

doEdit

protected void doEdit(javax.portlet.RenderRequest request,
                      javax.portlet.RenderResponse response)
               throws javax.portlet.PortletException,
                      IOException
Delegates to #processRequest(PortletRequest, PortletResponse, String, String).

Overrides:
doEdit in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException
See Also:
#processRequest(PortletRequest, PortletResponse, String, String)

doHelp

protected void doHelp(javax.portlet.RenderRequest request,
                      javax.portlet.RenderResponse response)
               throws javax.portlet.PortletException,
                      IOException
Delegates to #processRequest(PortletRequest, PortletResponse, String, String).

Overrides:
doHelp in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException
See Also:
#processRequest(PortletRequest, PortletResponse, String, String)

doCustom

protected void doCustom(javax.portlet.RenderRequest request,
                        javax.portlet.RenderResponse response)
                 throws javax.portlet.PortletException,
                        IOException
Delegates to #processRequest(PortletRequest, PortletResponse, String, String).

Throws:
javax.portlet.PortletException
IOException
See Also:
#processRequest(PortletRequest, PortletResponse, String, String)

processAction

public void processAction(javax.portlet.ActionRequest request,
                          javax.portlet.ActionResponse response)
                   throws javax.portlet.PortletException,
                          IOException
Delegates to #processRequest(PortletRequest, PortletResponse, String, String).

Stores the ActionResponse so that PortletEventService#broadcast can send events using StateAwareResponse.setEvent(javax.xml.namespace.QName, java.io.Serializable)

Specified by:
processAction in interface javax.portlet.Portlet
Overrides:
processAction in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException
See Also:
PortletEventService#broadcastToPortletListeners, #processRequest(PortletRequest, PortletResponse, String, String)

serveResource

public void serveResource(javax.portlet.ResourceRequest request,
                          javax.portlet.ResourceResponse response)
                   throws javax.portlet.PortletException,
                          IOException
Delegates to #processRequest(PortletRequest, PortletResponse, String, String).

Specified by:
serveResource in interface javax.portlet.ResourceServingPortlet
Overrides:
serveResource in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException
See Also:
#processRequest(PortletRequest, PortletResponse, String, String)

processRequest

protected void processRequest(javax.portlet.PortletRequest request,
                              javax.portlet.PortletResponse response,
                              String pageType)
                       throws javax.portlet.PortletException,
                              IOException
Consumes and processes all portlet requests. All the doX methods delegate to this method, including processAction and serveResource.

Parameters:
request -
response -
requestType -
pageType -
Throws:
javax.portlet.PortletException
IOException

processActionResponseState

protected void processActionResponseState(String wicketURL,
                                          String wicketFilterPath,
                                          String wicketFilterQuery,
                                          javax.portlet.PortletRequest request,
                                          javax.portlet.ActionResponse response,
                                          WicketResponseState responseState)
                                   throws javax.portlet.PortletException,
                                          IOException
Handles redirects set from processing the action. Checks the response state after the action has been processed by Wicket for the presence of a redirect URL, and if present, 'portletifies' the URL. If the URL is a redirect to within the scope of this portlet, leaves it to be handled in a subsequent render call, or if not, sends the redirect to the client. The recorded url is then used in by wicket in the subsequnt 'VIEW' requests by the portal, to render the correct Page.

Parameters:
wicketURL -
wicketFilterPath -
wicketFilterQuery -
request -
response -
responseState -
Throws:
javax.portlet.PortletException
IOException
See Also:
IRequestCycleSettings.REDIRECT_TO_RENDER


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.