org.jasig.web.service
Class AjaxPortletSupportService

java.lang.Object
  extended by org.jasig.web.service.AjaxPortletSupportService
All Implemented Interfaces:
AjaxPortletSupport

public class AjaxPortletSupportService
extends Object
implements AjaxPortletSupport

Service intended for annotation-based controllers.

Author:
Eric Dalquist, Jen Bourey

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jasig.web.service.AjaxPortletSupport
AjaxPortletSupport.ModelGenerator
 
Field Summary
static String SESSION_KEY
           
 
Fields inherited from interface org.jasig.web.service.AjaxPortletSupport
DEFAULT_AJAX_HANDLER_ERROR_KEY, DEFAULT_AJAX_SERVLET_NAME
 
Constructor Summary
AjaxPortletSupportService()
           
 
Method Summary
 String getAjaxHandlerErrorKey()
           
 Map<String,?> getAjaxModel(HttpServletRequest request, HttpServletResponse response)
          Gets the model for the request, if the model is null a 404 is sent to the browser and null is returned.
protected  String getAjaxServletUrl(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, String ajaxServletName, String sessionKey)
          Generate the servlet URL to redirect the AJAX request to for rendering the response model.
 ModelPasser getModelPasser()
           
 SessionKeyGenerator getSessionKeyGenerator()
           
 void redirectAjaxResponse(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, AjaxPortletSupport.ModelGenerator generator)
          Calls #redirectAjaxResponse(ActionRequest, ActionResponse, ModelGenerator)) passing AjaxPortletSupport.DEFAULT_AJAX_SERVLET_NAME for the servlet name.
 void redirectAjaxResponse(Map<String,?> model, javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Calls AjaxPortletSupport.redirectAjaxResponse(String, Map, ActionRequest, ActionResponse) passing AjaxPortletSupport.DEFAULT_AJAX_SERVLET_NAME for the servlet name.
 void redirectAjaxResponse(String ajaxServletName, javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, AjaxPortletSupport.ModelGenerator generator)
          Generates a new session key and uses that to pass the model to the servlet.
 void redirectAjaxResponse(String ajaxServletName, Map<String,?> model, javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
          Generates a new session key and uses that to pass the model to the servlet.
 void setAjaxHandlerErrorKey(String ajaxHandlerErrorKey)
          Model attribute used to pass an exception object to the rendering serlvet if one occurs from calling #handleRenderRequestInternal(javax.portlet.RenderRequest, javax.portlet.RenderResponse).
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_KEY

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

AjaxPortletSupportService

public AjaxPortletSupportService()
Method Detail

getSessionKeyGenerator

public SessionKeyGenerator getSessionKeyGenerator()

setSessionKeyGenerator

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


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 #handleRenderRequestInternal(javax.portlet.RenderRequest, javax.portlet.RenderResponse). Defaults to the value of AjaxPortletSupport.DEFAULT_AJAX_HANDLER_ERROR_KEY


redirectAjaxResponse

public void redirectAjaxResponse(Map<String,?> model,
                                 javax.portlet.ActionRequest request,
                                 javax.portlet.ActionResponse response)
                          throws IOException
Description copied from interface: AjaxPortletSupport
Calls AjaxPortletSupport.redirectAjaxResponse(String, Map, ActionRequest, ActionResponse) passing AjaxPortletSupport.DEFAULT_AJAX_SERVLET_NAME for the servlet name.

Specified by:
redirectAjaxResponse in interface AjaxPortletSupport
Throws:
IOException

redirectAjaxResponse

public final void redirectAjaxResponse(String ajaxServletName,
                                       Map<String,?> model,
                                       javax.portlet.ActionRequest request,
                                       javax.portlet.ActionResponse response)
                                throws IOException
Description copied from interface: AjaxPortletSupport
Generates a new session key and uses that to pass the model to the servlet. The response will be redirected to the ajax handling servlet by this method.

Specified by:
redirectAjaxResponse in interface AjaxPortletSupport
Parameters:
ajaxServletName - Name of the ajax servlet to redirect to
model - The data model to pass to the servlet
Throws:
IOException

redirectAjaxResponse

public void redirectAjaxResponse(javax.portlet.ActionRequest request,
                                 javax.portlet.ActionResponse response,
                                 AjaxPortletSupport.ModelGenerator generator)
                          throws IOException
Description copied from interface: AjaxPortletSupport
Calls #redirectAjaxResponse(ActionRequest, ActionResponse, ModelGenerator)) passing AjaxPortletSupport.DEFAULT_AJAX_SERVLET_NAME for the servlet name.

Specified by:
redirectAjaxResponse in interface AjaxPortletSupport
Throws:
IOException

redirectAjaxResponse

public void redirectAjaxResponse(String ajaxServletName,
                                 javax.portlet.ActionRequest request,
                                 javax.portlet.ActionResponse response,
                                 AjaxPortletSupport.ModelGenerator generator)
                          throws IOException
Description copied from interface: AjaxPortletSupport
Generates a new session key and uses that to pass the model to the servlet. The response will be redirected to the ajax handling servlet by this method. Handles any exceptions thrown by AjaxPortletSupport.ModelGenerator.generate(ActionRequest, ActionResponse) using AjaxPortletSupport.DEFAULT_AJAX_HANDLER_ERROR_KEY as the error key.

Specified by:
redirectAjaxResponse in interface AjaxPortletSupport
Parameters:
ajaxServletName - Name of the ajax servlet to redirect to
generator - ModelGenerator used to generate the model to pass
Throws:
IOException

getAjaxModel

public final Map<String,?> getAjaxModel(HttpServletRequest request,
                                        HttpServletResponse response)
                                 throws ServletRequestBindingException,
                                        IOException
Description copied from interface: AjaxPortletSupport
Gets the model for the request, if the model is null a 404 is sent to the browser and null is returned. If the model contains the key AjaxPortletSupport.DEFAULT_AJAX_HANDLER_ERROR_KEY a 500 is sent to the browser but the model is still returned for rendering.

Specified by:
getAjaxModel in interface AjaxPortletSupport
Throws:
ServletRequestBindingException
IOException

getAjaxServletUrl

protected String getAjaxServletUrl(javax.portlet.ActionRequest request,
                                   javax.portlet.ActionResponse response,
                                   String ajaxServletName,
                                   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


Copyright © 2010 Jasig. All Rights Reserved.