public abstract class SpringFormWidget<T> extends FormWidget
METADATA_KEY_NO_CONTENT
PARAM_WIDGET_ID
Constructor and Description |
---|
SpringFormWidget() |
Modifier and Type | Method and Description |
---|---|
protected org.springframework.web.bind.ServletRequestDataBinder |
createBinder(javax.servlet.http.HttpServletRequest request,
T formBackingObject)
Create a binder for the given request and form backing object.
|
protected abstract T |
formBackingObject(javax.servlet.http.HttpServletRequest request)
Create the form backing object.
|
org.springframework.web.servlet.ModelAndView |
handleRefresh()
Handle a refresh
|
org.springframework.web.servlet.ModelAndView |
handleSubmit()
Handle a submit
|
protected void |
initBinder(javax.servlet.http.HttpServletRequest request,
org.springframework.web.bind.ServletRequestDataBinder binder)
Called by
#createBinder(HttpServletRequest, T) to init the binder. |
protected abstract void |
onSubmit(javax.servlet.http.HttpServletRequest request,
T formBackingObject,
org.springframework.validation.BindingResult errors)
Do the actual submit operation, like updating database values.
|
protected void |
prepareBackingObjectOnRefresh(javax.servlet.http.HttpServletRequest request,
T formBackingObject)
Called when the form widget is refreshing to allow initialization of the backing object if
not already done in
formBackingObject(HttpServletRequest) . |
protected void |
prepareBackingObjectOnSubmit(javax.servlet.http.HttpServletRequest request,
T formBackingObject)
Called during submit of a form widget after the binder applied the request parameters to the
backing object, but before calling the validator.
|
protected void |
processFormSubmission(javax.servlet.http.HttpServletRequest request,
T formBackingObject,
org.springframework.validation.BindingResult errors) |
void |
setValidator(org.springframework.validation.Validator validator)
Set the validator to validate the submitted form backing object.
|
protected boolean |
suppressValidation(javax.servlet.http.HttpServletRequest request,
T formBackingObject)
Whether to suppress validation for the current submit
|
protected void |
validateForm(T formBackingObject,
org.springframework.validation.BindingResult errors) |
handleRequest, initParameters
determineOutputType, getAttribute, getBooleanParameter, getGroupName, getIntParameter, getIntParameter, getLongArrayParameter, getLongParameter, getLongParameter, getParameter, getParameter, getParameterEscaped, getParameterEscaped, getParameters, getRequest, getResponse, getResponseMetadata, getStringArrayParameter, getViewIdentifier, getWidgetId, isSuccess, setAttribute, setGroupName, setParameter, setRequest, setResponse, setResponseMetadata, setSuccess
protected org.springframework.web.bind.ServletRequestDataBinder createBinder(javax.servlet.http.HttpServletRequest request, T formBackingObject)
request
- the current requestformBackingObject
- the backing objectprotected abstract T formBackingObject(javax.servlet.http.HttpServletRequest request)
prepareBackingObjectOnRefresh(HttpServletRequest, Object)
or
prepareBackingObjectOnSubmit(HttpServletRequest, Object)
.request
- the current requestpublic org.springframework.web.servlet.ModelAndView handleRefresh()
FormWidget
handleRefresh
in class FormWidget
public org.springframework.web.servlet.ModelAndView handleSubmit()
FormWidget
handleSubmit
in class FormWidget
protected void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder)
#createBinder(HttpServletRequest, T)
to init the binder. This allows
registering custom editors for certain fields of the backing object class.request
- the current requestbinder
- the binderDataBinder.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)
protected abstract void onSubmit(javax.servlet.http.HttpServletRequest request, T formBackingObject, org.springframework.validation.BindingResult errors)
request
- the current requestformBackingObject
- the form backing objecterrors
- for adding errors that occur during the submit operationprotected void prepareBackingObjectOnRefresh(javax.servlet.http.HttpServletRequest request, T formBackingObject)
formBackingObject(HttpServletRequest)
. The default
implementation does nothing.request
- the current requestformBackingObject
- the backing objectprotected void prepareBackingObjectOnSubmit(javax.servlet.http.HttpServletRequest request, T formBackingObject)
request
- the current requestformBackingObject
- the backing objectprotected void processFormSubmission(javax.servlet.http.HttpServletRequest request, T formBackingObject, org.springframework.validation.BindingResult errors)
public void setValidator(org.springframework.validation.Validator validator)
validator
- the validator to use. If null no validation will be done.protected boolean suppressValidation(javax.servlet.http.HttpServletRequest request, T formBackingObject)
request
- the current requestformBackingObject
- the backing object that will be validatedprotected void validateForm(T formBackingObject, org.springframework.validation.BindingResult errors)
Copyright © 2019 Communote team. All rights reserved.