org.jasig.web.portlet.mvc
Class AbstractAjaxController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.portlet.context.PortletApplicationObjectSupport
          extended by org.springframework.web.portlet.handler.PortletContentGenerator
              extended by org.springframework.web.portlet.mvc.AbstractController
                  extended by org.jasig.web.portlet.mvc.AbstractAjaxController
All Implemented Interfaces:
ApplicationContextAware, PortletContextAware, Controller

public abstract class AbstractAjaxController
extends AbstractController

Base class for AJAX portlet callbacks that handles passing the model to the ajax response servlet via a unique random attribute.

Version:
$Revision$
Author:
Eric Dalquist

Field Summary
static String DEFAULT_AJAX_HANDLER_ERROR_KEY
           
static String DEFAULT_AJAX_SERVLET_NAME
           
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
AbstractAjaxController()
           
 
Method Summary
 String getAjaxHandlerErrorKey()
           
 String getAjaxServletName()
           
protected  String getAjaxServletUrl(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, String sessionKey)
          Generate the servlet URL to redirect the AJAX request to for rendering the response model.
 ModelPasser getModelPasser()
           
 SessionKeyGenerator getSessionKeyGenerator()
           
protected  void handleActionRequestInternal(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
           
protected abstract  Map<Object,Object> handleAjaxRequestInternal(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Called by handleActionRequestInternal(ActionRequest, ActionResponse) to handle the ajax callback.
 void setAjaxHandlerErrorKey(String ajaxHandlerErrorKey)
          Model attribute used to pass an exception object to the rendering serlvet if one occurs from calling AbstractController.handleRenderRequestInternal(javax.portlet.RenderRequest, javax.portlet.RenderResponse).
 void setAjaxServletName(String ajaxServletName)
          The path to the rendering serlvet do redirect the request to after the model data has been passed.
 void setModelPasser(ModelPasser modelPasser)
          Used to pass the model data to the rendering servlet.
 void setSessionKeyGenerator(SessionKeyGenerator sessionKeyGenerator)
          Used to generate unique keys within a portlet session.
 
Methods inherited from class org.springframework.web.portlet.mvc.AbstractController
handleActionRequest, handleRenderRequest, handleRenderRequestInternal, isRenderWhenMinimized, isSynchronizeOnSession, setRenderWhenMinimized, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.portlet.handler.PortletContentGenerator
applyCacheSeconds, cacheForSeconds, check, checkAndPrepare, checkAndPrepare, getCacheSeconds, isRequireSession, preventCaching, setCacheSeconds, setRequireSession
 
Methods inherited from class org.springframework.web.portlet.context.PortletApplicationObjectSupport
getPortletContext, getTempDir, isContextRequired, setPortletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_AJAX_SERVLET_NAME

public static final String DEFAULT_AJAX_SERVLET_NAME
See Also:
Constant Field Values

DEFAULT_AJAX_HANDLER_ERROR_KEY

public static final String DEFAULT_AJAX_HANDLER_ERROR_KEY
See Also:
Constant Field Values
Constructor Detail

AbstractAjaxController

public AbstractAjaxController()
Method Detail

getSessionKeyGenerator

public SessionKeyGenerator getSessionKeyGenerator()

setSessionKeyGenerator

public void setSessionKeyGenerator(SessionKeyGenerator sessionKeyGenerator)
Used to generate unique keys within a portlet session. Defaults to DefaultSessionKeyGenerator


getModelPasser

public ModelPasser getModelPasser()

setModelPasser

public void setModelPasser(ModelPasser modelPasser)
Used to pass the model data to the rendering servlet. Defaults to DefaultModelPasser


getAjaxHandlerErrorKey

public String getAjaxHandlerErrorKey()

setAjaxHandlerErrorKey

public void setAjaxHandlerErrorKey(String ajaxHandlerErrorKey)
Model attribute used to pass an exception object to the rendering serlvet if one occurs from calling AbstractController.handleRenderRequestInternal(javax.portlet.RenderRequest, javax.portlet.RenderResponse). Defaults to the value of DEFAULT_AJAX_HANDLER_ERROR_KEY


getAjaxServletName

public String getAjaxServletName()

setAjaxServletName

public void setAjaxServletName(String ajaxServletName)
The path to the rendering serlvet do redirect the request to after the model data has been passed. Defaults to the value of DEFAULT_AJAX_SERVLET_NAME


handleActionRequestInternal

protected final void handleActionRequestInternal(javax.portlet.ActionRequest request,
                                                 javax.portlet.ActionResponse response)
                                          throws Exception
Overrides:
handleActionRequestInternal in class AbstractController
Throws:
Exception

getAjaxServletUrl

protected String getAjaxServletUrl(javax.portlet.ActionRequest request,
                                   javax.portlet.ActionResponse response,
                                   String sessionKey)
                            throws UnsupportedEncodingException
Generate the servlet URL to redirect the AJAX request to for rendering the response model. The URL will be encoded via PortletResponse#encodeURL(String) before the redirect is sent.

Parameters:
sessionKey - The session key to provide on the URL
Throws:
UnsupportedEncodingException

handleAjaxRequestInternal

protected abstract Map<Object,Object> handleAjaxRequestInternal(javax.portlet.ActionRequest request,
                                                                javax.portlet.ActionResponse response)
                                                         throws Exception
Called by handleActionRequestInternal(ActionRequest, ActionResponse) to handle the ajax callback. The returned model will be passed to the AjaxResponseController via the ModelPasser.passModelToServlet(ActionRequest, ActionResponse, String, Map) method.

Throws:
Exception
See Also:
handleActionRequestInternal(ActionRequest, ActionResponse)


Copyright © 2009 Jasig. All Rights Reserved.