JSF-Spring

de.mindmatters.faces.spring.context.servlet.controller
Class SimpleActionController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by de.mindmatters.faces.spring.context.servlet.controller.AbstractFacesController
                      extended by de.mindmatters.faces.spring.context.servlet.controller.SimpleActionController
All Implemented Interfaces:
ActionSource, ApplicationContextAware, ServletContextAware, Controller

public class SimpleActionController
extends AbstractFacesController
implements ActionSource

This Controller implements an ActionSource and fullfills completely the contract of an ActionSource. So this Controller can be used like a UICommand which will be fully configured and mapped in the FacesDispatcherServlet's application context.

For more information please have a look at the UICommand and ActionSource documentations.

Author:
Andreas Kuhrwahl

Field Summary
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
SimpleActionController()
           
 
Method Summary
 void addActionListener(ActionListener listener)
          

Add a new ActionListener to the set of listeners interested in being notified when ActionEvents occur.

 MethodBinding getAction()
          

Return the MethodBindingpointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property.

 MethodBinding getActionListener()
          

Return the MethodBinding pointing at an action listener method to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending upon the value of the immediate property.

 ActionListener[] getActionListeners()
          

Return the set of registered ActionListeners for this ActionSource instance.

protected  ModelAndView handleRequestInternal(FacesContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Template method.
 boolean isImmediate()
          

Return a flag indicating that the default ActionListener provided by the JavaServer Faces implementation should be executed immediately (that is, during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase.

protected  void processAction(FacesContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionEvent event)
          Process the request.
 void removeActionListener(ActionListener listener)
          

Remove an existing ActionListener (if any) from the set of listeners interested in being notified when ActionEvents occur.

 void setAction(MethodBinding action)
          

Set the MethodBinding pointing at the appication action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property.

 void setActionListener(MethodBinding actionListener)
          

Set the MethodBinding pointing at an action listener method to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending upon the value of the immmediate property.

 void setActionListeners(java.util.List actionListeners)
          Sets the list of new ActionListeners interested in being notified when ActionEvents occur.
 void setActionSource(ActionSource actionSource)
          Sets the ActionSource implementation this controller should use as delegate.
 void setImmediate(boolean immediate)
          

Set the "immediate execution" flag for this UIComponent.

 
Methods inherited from class de.mindmatters.faces.spring.context.servlet.controller.AbstractFacesController
handleRequestInternal
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleActionController

public SimpleActionController()
Method Detail

handleRequestInternal

protected final ModelAndView handleRequestInternal(FacesContext context,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response)
Template method. Subclasses must implement this. The contract is the same as for handleRequest.

Specified by:
handleRequestInternal in class AbstractFacesController
Parameters:
context - FacesContext for the current request
request - current HTTP request
response - current HTTP response
Returns:
a ModelAndView to render, or null if handled directly
See Also:
AbstractController.handleRequest(HttpServletRequest, HttpServletResponse)

processAction

protected void processAction(FacesContext context,
                             javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             ActionEvent event)
Process the request. This method will be invoked after the ActionListeners (added by setActionListeners(List)) are notified and before the Action and ActionListener MethodBindings of this ActionSource will be processed. May be overriden in subclasses.

Parameters:
context - FacesContext for the current request
request - current HTTP request
response - current HTTP response
event - current ActionEvent

setActionSource

public final void setActionSource(ActionSource actionSource)
Sets the ActionSource implementation this controller should use as delegate. Default ActionSource is a UICommand instance.

Parameters:
actionSource - the ActionSource to use for internal purposes.

addActionListener

public final void addActionListener(ActionListener listener)

Add a new ActionListener to the set of listeners interested in being notified when ActionEvents occur.

Specified by:
addActionListener in interface ActionSource
Parameters:
listener - The ActionListener to be added

getAction

public final MethodBinding getAction()

Return the MethodBindingpointing at the application action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property.

Specified by:
getAction in interface ActionSource

getActionListener

public final MethodBinding getActionListener()

Return the MethodBinding pointing at an action listener method to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending upon the value of the immediate property.

Specified by:
getActionListener in interface ActionSource

getActionListeners

public final ActionListener[] getActionListeners()

Return the set of registered ActionListeners for this ActionSource instance. If there are no registered listeners, a zero-length array is returned.

Specified by:
getActionListeners in interface ActionSource

isImmediate

public final boolean isImmediate()

Return a flag indicating that the default ActionListener provided by the JavaServer Faces implementation should be executed immediately (that is, during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase. The default value for this property must be false.

Specified by:
isImmediate in interface ActionSource

removeActionListener

public final void removeActionListener(ActionListener listener)

Remove an existing ActionListener (if any) from the set of listeners interested in being notified when ActionEvents occur.

Specified by:
removeActionListener in interface ActionSource
Parameters:
listener - The ActionListener to be removed

setAction

public final void setAction(MethodBinding action)

Set the MethodBinding pointing at the appication action to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property.

Any method referenced by such an expression must be public, with a return type of String, and accept no parameters.

Specified by:
setAction in interface ActionSource
Parameters:
action - The new MethodBinding expression

setActionListener

public final void setActionListener(MethodBinding actionListener)

Set the MethodBinding pointing at an action listener method to be invoked, if this UIComponent is activated by the user, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending upon the value of the immmediate property.

Any method referenced by such an expression must be public, with a return type of void, and accept a single parameter of type ActionEvent.

Specified by:
setActionListener in interface ActionSource
Parameters:
actionListener - The new method binding expression

setImmediate

public final void setImmediate(boolean immediate)

Set the "immediate execution" flag for this UIComponent.

Specified by:
setImmediate in interface ActionSource
Parameters:
immediate - The new immediate execution flag

setActionListeners

public final void setActionListeners(java.util.List actionListeners)
Sets the list of new ActionListeners interested in being notified when ActionEvents occur.

Parameters:
actionListeners - the ActionListener instance to use

JSF-Spring

Copyright © 2006 mindmatters GmbH & Co. KG