org.appfuse.webapp.action
Class BaseFormController

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 org.springframework.web.servlet.mvc.BaseCommandController
                      extended by org.springframework.web.servlet.mvc.AbstractFormController
                          extended by org.springframework.web.servlet.mvc.SimpleFormController
                              extended by org.appfuse.webapp.action.BaseFormController
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.mvc.Controller
Direct Known Subclasses:
FileUploadController, SignupController, UserFormController

public class BaseFormController
extends org.springframework.web.servlet.mvc.SimpleFormController

Implementation of SimpleFormController that contains convenience methods for subclasses. For example, getting the current user and saving messages/errors. This class is intended to be a base class for all Form controllers.

View Source

Author:
Matt Raible

Field Summary
protected  java.lang.String cancelView
           
protected  org.apache.commons.logging.Log log
           
protected  org.appfuse.service.MailEngine mailEngine
           
protected  org.springframework.mail.SimpleMailMessage message
           
protected  java.lang.String MESSAGES_KEY
           
protected  java.lang.String templateName
           
 
Fields inherited from class org.springframework.web.servlet.mvc.BaseCommandController
DEFAULT_COMMAND_NAME
 
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
BaseFormController()
           
 
Method Summary
 java.lang.String getCancelView()
           
 java.util.Map getConfiguration()
          Convenience method to get the Configuration HashMap from the servlet context.
 java.lang.String getText(java.lang.String msgKey, java.util.Locale locale)
          Convenience method for getting a i18n key's value.
 java.lang.String getText(java.lang.String msgKey, java.lang.Object[] args, java.util.Locale locale)
          Convenience method for getting a i18n key's value with arguments.
 java.lang.String getText(java.lang.String msgKey, java.lang.String arg, java.util.Locale locale)
          Convenient method for getting a i18n key's value with a single string argument.
 org.appfuse.service.UserManager getUserManager()
           
protected  void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder)
          Set up a custom property editor for converting form inputs to real objects
 org.springframework.web.servlet.ModelAndView processFormSubmission(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object command, org.springframework.validation.BindException errors)
          Default behavior for FormControllers - redirect to the successView when the cancel button has been pressed.
 void saveMessage(javax.servlet.http.HttpServletRequest request, java.lang.String msg)
           
protected  void sendUserMessage(org.appfuse.model.User user, java.lang.String msg, java.lang.String url)
          Convenience message to send messages to users, includes app URL as footer.
 void setCancelView(java.lang.String cancelView)
          Indicates what view to use when the cancel button has been pressed.
 void setMailEngine(org.appfuse.service.MailEngine mailEngine)
           
 void setMessage(org.springframework.mail.SimpleMailMessage message)
           
 void setTemplateName(java.lang.String templateName)
           
 void setUserManager(org.appfuse.service.UserManager userManager)
           
 
Methods inherited from class org.springframework.web.servlet.mvc.SimpleFormController
doSubmitAction, getFormView, getSuccessView, isFormChangeRequest, isFormChangeRequest, onFormChange, onFormChange, onSubmit, onSubmit, onSubmit, referenceData, referenceData, setFormView, setSuccessView, showForm, showForm, suppressValidation
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractFormController
currentFormObject, formBackingObject, getCommand, getErrorsForNewForm, getFormSessionAttributeName, getFormSessionAttributeName, handleInvalidSubmit, handleRequestInternal, isBindOnNewForm, isFormSubmission, isSessionForm, onBindOnNewForm, onBindOnNewForm, setBindOnNewForm, setSessionForm, showForm, showForm, showNewForm
 
Methods inherited from class org.springframework.web.servlet.mvc.BaseCommandController
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, initApplicationContext, isValidateOnBinding, onBind, onBind, onBindAndValidate, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, suppressBinding, suppressValidation, useDirectFieldAccess
 
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, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final transient org.apache.commons.logging.Log log

MESSAGES_KEY

protected final java.lang.String MESSAGES_KEY
See Also:
Constant Field Values

mailEngine

protected org.appfuse.service.MailEngine mailEngine

message

protected org.springframework.mail.SimpleMailMessage message

templateName

protected java.lang.String templateName

cancelView

protected java.lang.String cancelView
Constructor Detail

BaseFormController

public BaseFormController()
Method Detail

setUserManager

public void setUserManager(org.appfuse.service.UserManager userManager)

getUserManager

public org.appfuse.service.UserManager getUserManager()

saveMessage

public void saveMessage(javax.servlet.http.HttpServletRequest request,
                        java.lang.String msg)

getText

public java.lang.String getText(java.lang.String msgKey,
                                java.util.Locale locale)
Convenience method for getting a i18n key's value. Calling getMessageSourceAccessor() is used because the RequestContext variable is not set in unit tests b/c there's no DispatchServlet Request.

Parameters:
msgKey -
locale - the current locale
Returns:

getText

public java.lang.String getText(java.lang.String msgKey,
                                java.lang.String arg,
                                java.util.Locale locale)
Convenient method for getting a i18n key's value with a single string argument.

Parameters:
msgKey -
arg -
locale - the current locale
Returns:

getText

public java.lang.String getText(java.lang.String msgKey,
                                java.lang.Object[] args,
                                java.util.Locale locale)
Convenience method for getting a i18n key's value with arguments.

Parameters:
msgKey -
args -
locale - the current locale
Returns:

getConfiguration

public java.util.Map getConfiguration()
Convenience method to get the Configuration HashMap from the servlet context.

Returns:
the user's populated form from the session

processFormSubmission

public org.springframework.web.servlet.ModelAndView processFormSubmission(javax.servlet.http.HttpServletRequest request,
                                                                          javax.servlet.http.HttpServletResponse response,
                                                                          java.lang.Object command,
                                                                          org.springframework.validation.BindException errors)
                                                                   throws java.lang.Exception
Default behavior for FormControllers - redirect to the successView when the cancel button has been pressed.

Overrides:
processFormSubmission in class org.springframework.web.servlet.mvc.SimpleFormController
Throws:
java.lang.Exception

initBinder

protected void initBinder(javax.servlet.http.HttpServletRequest request,
                          org.springframework.web.bind.ServletRequestDataBinder binder)
Set up a custom property editor for converting form inputs to real objects

Overrides:
initBinder in class org.springframework.web.servlet.mvc.BaseCommandController

sendUserMessage

protected void sendUserMessage(org.appfuse.model.User user,
                               java.lang.String msg,
                               java.lang.String url)
Convenience message to send messages to users, includes app URL as footer.

Parameters:
user -
msg -
url -

setMailEngine

public void setMailEngine(org.appfuse.service.MailEngine mailEngine)

setMessage

public void setMessage(org.springframework.mail.SimpleMailMessage message)

setTemplateName

public void setTemplateName(java.lang.String templateName)

setCancelView

public final void setCancelView(java.lang.String cancelView)
Indicates what view to use when the cancel button has been pressed.


getCancelView

public final java.lang.String getCancelView()


Copyright © 2003-2007. All Rights Reserved.