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

java.lang.Object
  extended by org.apache.wicket.protocol.http.portlet.WicketFilterPortletContext

public class WicketFilterPortletContext
extends Object

Handles Portlet specific filtering requirements.

The WicketFilterPortletContext first checks if it is a Portlet based request or a direct browser (servlet) request. If the request is a direct browser request it simply delegates the request to the WicketFilter and "normal" Wicket web application handling continues. This allows deploying the same Wicket application (with the same web.xml) as a normal web application too (as long as you don't use portlet specific features within your application).

If the request is dispatched from the WicketPortlet (easily determined from request attributes), the WicketPortletFilter wraps the servlet request and response objects with specialized portlet environment versions. Furthermore, the Servlet Session object will be wrapped to provide an isolated PORTLET_SCOPED session to Wicket to support multiple windows of the same portlet. And the RenderStrategy IRequestCycleSettings.REDIRECT_TO_RENDER will have to be enforced when invoked from portlet processAction, otherwise IRequestCycleSettings.ONE_PASS_RENDER. Thereafter, the WicketFilterPortletContext can let the standard WicketFilter handle the request as if it were a "normal" web based request.

Author:
Ate Douma
See Also:
WicketFilter

Constructor Summary
WicketFilterPortletContext()
           
 
Method Summary
 boolean createPortletRequestContext(WebRequest request, WebResponse response)
          Factory method which will delegate to newPortletRequestContext(ServletWebRequest, WebResponse) to create the PortletRequestContext if the request is in a portlet context.
 String decodePortletWindowId(String pathInfo)
          FIXME javadoc Try to extract the portlet's window id from the request url.
 String encodeWindowIdInPath(String windowId, CharSequence path)
          Encodes the given path portlet window id.
 String getServletResourceUrlPortletWindowIdPrefix()
           
 void initFilter(javax.servlet.FilterConfig filterConfig, WebApplication webApplication)
          Overrides render strategy and adds the PortletInvalidMarkupFilter filter.
protected  void newPortletRequestContext(ServletWebRequest request, WebResponse response)
          Factory method to create the PortletRequestContext.
 boolean setupFilter(javax.servlet.FilterConfig config, FilterRequestContext filterRequestContext, String filterPath)
          Sets up the filter to process a given request cycle.
 String stripWindowIdFromPathInfo(String pathInfo)
          FIXME javadoc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WicketFilterPortletContext

public WicketFilterPortletContext()
Method Detail

initFilter

public void initFilter(javax.servlet.FilterConfig filterConfig,
                       WebApplication webApplication)
                throws javax.servlet.ServletException
Overrides render strategy and adds the PortletInvalidMarkupFilter filter.

Parameters:
webApplication -
Throws:
javax.servlet.ServletException
See Also:
PortletInvalidMarkupFilter

setupFilter

public boolean setupFilter(javax.servlet.FilterConfig config,
                           FilterRequestContext filterRequestContext,
                           String filterPath)
                    throws IOException,
                           javax.servlet.ServletException
Sets up the filter to process a given request cycle. Potentially wraps the request and response objects with portlet specific wrappers.

Also sets up the session proxy using Apache Portals Bridge to ensure portlet session isolation. This is an option feature of Portal 2.0 spec so we just use portal bridges instead as it guarantees us support.

Parameters:
config - filter configuration
filterRequestContext -
filterPath -
Returns:
true if we are in a portlet environment
Throws:
IOException
javax.servlet.ServletException
See Also:
org.apache.portals.bridges.util.ServletPortletSessionProxy

createPortletRequestContext

public boolean createPortletRequestContext(WebRequest request,
                                           WebResponse response)
Factory method which will delegate to newPortletRequestContext(ServletWebRequest, WebResponse) to create the PortletRequestContext if the request is in a portlet context.

Parameters:
request -
response -
Returns:
true if running in a portlet context.

getServletResourceUrlPortletWindowIdPrefix

public String getServletResourceUrlPortletWindowIdPrefix()
Returns:
the unique, reserved string used to prefix the portlet's "window id" in the URL.
See Also:
SERVLET_RESOURCE_URL_PORTLET_WINDOW_ID_PREFIX

decodePortletWindowId

public String decodePortletWindowId(String pathInfo)
FIXME javadoc Try to extract the portlet's window id from the request url.

Parameters:
pathInfo - the url relative to the servlet context and filter path
Returns:
the window id, or null if it couldn't be decoded, with no leading forward slash

stripWindowIdFromPathInfo

public String stripWindowIdFromPathInfo(String pathInfo)
FIXME javadoc

If the pathInfo contains the portlet window id namespace prefix, remove it.

Parameters:
pathInfo -
Returns:

encodeWindowIdInPath

public String encodeWindowIdInPath(String windowId,
                                   CharSequence path)
Encodes the given path portlet window id.

Parameters:
windowId -
path -
Returns:

newPortletRequestContext

protected void newPortletRequestContext(ServletWebRequest request,
                                        WebResponse response)
Factory method to create the PortletRequestContext.

Parameters:
request -
response -
See Also:
createPortletRequestContext(WebRequest, WebResponse), PortletRequestContext


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