public class PersonFormController
extends org.springframework.web.servlet.mvc.SimpleFormController
PatientFormController
DEFAULT_COMMAND_NAME
Constructor and Description |
---|
PersonFormController() |
Modifier and Type | Method and Description |
---|---|
protected Object |
formBackingObject(javax.servlet.http.HttpServletRequest request)
Retrieve a backing object for the current form from the given request.
|
static <P extends Person> |
getMiniPerson(P person,
String name,
String gender,
String date,
String age)
Add the given name, gender, and birthdate/age to the given Person
|
protected void |
initBinder(javax.servlet.http.HttpServletRequest request,
org.springframework.web.bind.ServletRequestDataBinder binder)
Allows for other Objects to be used as values in input tags.
|
protected org.springframework.web.servlet.ModelAndView |
onSubmit(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Object command,
org.springframework.validation.BindException errors)
Submit callback with all parameters.
|
protected org.springframework.web.servlet.ModelAndView |
processFormSubmission(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Object obj,
org.springframework.validation.BindException errors)
This implementation calls
SimpleFormController.showForm(HttpServletRequest, HttpServletResponse, BindException)
in case of errors, and delegates to the full
SimpleFormController.onSubmit(HttpServletRequest, HttpServletResponse, Object, BindException) 's
variant else. |
protected Map<String,Object> |
referenceData(javax.servlet.http.HttpServletRequest request,
Object obj,
org.springframework.validation.Errors err)
Create a reference data map for the given request and command,
consisting of bean name/bean instance pairs as expected by ModelAndView.
|
protected Person |
setupFormBackingObject(Person person)
Setup the person object.
|
protected Map |
setupReferenceData(Map map,
Person person)
Setup the reference map object.
|
protected org.springframework.web.servlet.ModelAndView |
showForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.validation.BindException errors)
Redirects to the patient form if the given personId points to a patient.
|
protected org.springframework.web.servlet.ModelAndView |
showForm(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.validation.BindException errors,
Map controlModel)
Redirects to the patient form if the given personId points to a patient.
|
protected void |
updatePersonAddresses(javax.servlet.http.HttpServletRequest request,
Person person,
org.springframework.validation.BindException errors)
Updates person addresses based on request parameters
|
protected void |
updatePersonAttributes(javax.servlet.http.HttpServletRequest request,
org.springframework.validation.BindException errors,
Person person)
Updates person attributes based on request parameters
|
protected void |
updatePersonNames(javax.servlet.http.HttpServletRequest request,
Person person)
Updates person names based on request parameters
|
doSubmitAction, getFormView, getSuccessView, isFormChangeRequest, isFormChangeRequest, onFormChange, onFormChange, onSubmit, onSubmit, referenceData, setFormView, setSuccessView, suppressValidation
currentFormObject, getCommand, getErrorsForNewForm, getFormSessionAttributeName, getFormSessionAttributeName, handleInvalidSubmit, handleRequestInternal, isBindOnNewForm, isFormSubmission, isSessionForm, onBindOnNewForm, onBindOnNewForm, setBindOnNewForm, setSessionForm, showForm, showForm, showNewForm
bindAndValidate, checkCommand, createBinder, createCommand, getBindingErrorProcessor, getCommandClass, getCommandName, getMessageCodesResolver, getPropertyEditorRegistrars, getValidator, getValidators, getWebBindingInitializer, initApplicationContext, isValidateOnBinding, onBind, onBind, onBindAndValidate, prepareBinder, setBindingErrorProcessor, setCommandClass, setCommandName, setMessageCodesResolver, setPropertyEditorRegistrar, setPropertyEditorRegistrars, setValidateOnBinding, setValidator, setValidators, setWebBindingInitializer, suppressBinding, suppressValidation, suppressValidation, useDirectFieldAccess
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, preventCaching, setAlwaysMustRevalidate, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
protected void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder) throws Exception
initBinder
in class org.springframework.web.servlet.mvc.BaseCommandController
request
- current HTTP requestbinder
- the new binder instanceException
- in case of invalid state or argumentsBaseCommandController.initBinder(javax.servlet.http.HttpServletRequest,
org.springframework.web.bind.ServletRequestDataBinder)
protected Object formBackingObject(javax.servlet.http.HttpServletRequest request) throws Exception
org.springframework.web.servlet.mvc.AbstractFormController
The properties of the form object will correspond to the form field values in your form view. This object will be exposed in the model under the specified command name, to be accessed under that name in the view: for example, with a "spring:bind" tag. The default command name is "command".
Note that you need to activate session form mode to reuse the form-backing object across the entire form workflow. Else, a new instance of the command class will be created for each submission attempt, just using this backing object as template for the initial form.
The default implementation calls BaseCommandController.createCommand()
,
creating a new empty instance of the specified command class.
Subclasses can override this to provide a preinitialized backing object.
formBackingObject
in class org.springframework.web.servlet.mvc.AbstractFormController
request
- current HTTP requestException
- in case of invalid state or argumentsBaseCommandController.setCommandName(java.lang.String)
,
BaseCommandController.setCommandClass(java.lang.Class)
,
BaseCommandController.createCommand()
protected org.springframework.web.servlet.ModelAndView showForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.validation.BindException errors) throws Exception
showForm
in class org.springframework.web.servlet.mvc.SimpleFormController
request
- current HTTP requestresponse
- current HTTP responseerrors
- validation errors holdernull
if handled directlyException
- in case of invalid state or argumentsSimpleFormController.showForm(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse, org.springframework.validation.BindException)
protected org.springframework.web.servlet.ModelAndView showForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.validation.BindException errors, Map controlModel) throws Exception
showForm
in class org.springframework.web.servlet.mvc.SimpleFormController
request
- current HTTP requesterrors
- validation errors holdercontrolModel
- model map containing controller-specific control data
(e.g. current page in wizard-style controllers or special error message)Exception
- in case of invalid state or argumentsSimpleFormController.showForm(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse, org.springframework.validation.BindException,
java.util.Map)
protected org.springframework.web.servlet.ModelAndView processFormSubmission(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object obj, org.springframework.validation.BindException errors) throws Exception
org.springframework.web.servlet.mvc.SimpleFormController
SimpleFormController.showForm(HttpServletRequest, HttpServletResponse, BindException)
in case of errors, and delegates to the full
SimpleFormController.onSubmit(HttpServletRequest, HttpServletResponse, Object, BindException)
's
variant else.
This can only be overridden to check for an action that should be executed
without respect to binding errors, like a cancel action. To just handle successful
submissions without binding errors, override one of the onSubmit
methods or SimpleFormController.doSubmitAction(java.lang.Object)
.
processFormSubmission
in class org.springframework.web.servlet.mvc.SimpleFormController
request
- current servlet requestresponse
- current servlet responseobj
- form object with request parameters bound onto iterrors
- holder without errors (subclass can add errors if it wants to)null
Exception
- in case of errorsAbstractFormController.processFormSubmission(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse, java.lang.Object,
org.springframework.validation.BindException)
protected org.springframework.web.servlet.ModelAndView onSubmit(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object command, org.springframework.validation.BindException errors) throws Exception
org.springframework.web.servlet.mvc.SimpleFormController
The default implementation delegates to SimpleFormController.onSubmit(Object, BindException)
.
For simply performing a submit action and rendering the specified success
view, consider implementing SimpleFormController.doSubmitAction(java.lang.Object)
rather than an
onSubmit
variant.
Subclasses can override this to provide custom submission handling like storing the object to the database. Implementations can also perform custom validation and call showForm to return to the form. Do not implement multiple onSubmit methods: In that case, just this method will be called by the controller.
Call errors.getModel()
to populate the ModelAndView model
with the command and the Errors instance, under the specified command name,
as expected by the "spring:bind" tag.
onSubmit
in class org.springframework.web.servlet.mvc.SimpleFormController
request
- current servlet requestresponse
- current servlet responsecommand
- form object with request parameters bound onto iterrors
- Errors instance without errors (subclass can add errors if it wants to)null
Exception
- in case of errorsSimpleFormController.onSubmit(Object, BindException)
,
SimpleFormController.doSubmitAction(java.lang.Object)
,
SimpleFormController.showForm(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.springframework.validation.BindException)
,
Errors
,
BindException.getModel()
protected Map<String,Object> referenceData(javax.servlet.http.HttpServletRequest request, Object obj, org.springframework.validation.Errors err) throws Exception
org.springframework.web.servlet.mvc.SimpleFormController
The default implementation delegates to SimpleFormController.referenceData(HttpServletRequest)
.
Subclasses can override this to set reference data used in the view.
referenceData
in class org.springframework.web.servlet.mvc.SimpleFormController
request
- current HTTP requestobj
- form object with request parameters bound onto iterr
- validation errors holdernull
if noneException
- in case of invalid state or argumentsModelAndView
protected void updatePersonAttributes(javax.servlet.http.HttpServletRequest request, org.springframework.validation.BindException errors, Person person)
request
- errors
- person
- protected void updatePersonNames(javax.servlet.http.HttpServletRequest request, Person person)
request
- person
- protected void updatePersonAddresses(javax.servlet.http.HttpServletRequest request, Person person, org.springframework.validation.BindException errors) throws ParseException
request
- person
- errors
- ParseException
protected Person setupFormBackingObject(Person person)
person
- protected Map setupReferenceData(Map map, Person person) throws Exception
person
- Exception
public static <P extends Person> void getMiniPerson(P person, String name, String gender, String date, String age)
P
- Should be a Patient or User objectperson
- name
- gender
- date
- birthdateage
- Copyright © 2015 OpenMRS Inc.. All rights reserved.