|
Spring Web Flow | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.webflow.mvc.view.AbstractMvcView
public abstract class AbstractMvcView
Base view implementation for the Spring Web MVC Servlet and Spring Web MVC Portlet frameworks.
Field Summary |
---|
Fields inherited from interface org.springframework.webflow.execution.View |
---|
RENDER_FRAGMENTS_ATTRIBUTE, USER_EVENT_STATE_ATTRIBUTE |
Constructor Summary | |
---|---|
AbstractMvcView(org.springframework.web.servlet.View view,
RequestContext requestContext)
Creates a new MVC view. |
Method Summary | |
---|---|
protected void |
addDefaultMapping(DefaultMapper mapper,
java.lang.String parameter,
java.lang.Object model)
Adds a DefaultMapping between the given request parameter name and a matching model field. |
protected void |
addDefaultMappings(DefaultMapper mapper,
java.util.Set<java.lang.String> parameterNames,
java.lang.Object model)
Add a DefaultMapping instance for all incoming request parameters except those having a special field
marker prefix. |
protected void |
addEmptyValueMapping(DefaultMapper mapper,
java.lang.String field,
java.lang.Object model)
Adds a special DefaultMapping that results in setting the target field on the model to an empty value
(typically null). |
protected void |
addMapping(DefaultMapper mapper,
BinderConfiguration.Binding binding,
java.lang.Object model)
Creates and adds a DefaultMapping for the given BinderConfiguration.Binding . |
protected void |
addModelBindings(DefaultMapper mapper,
java.util.Set<java.lang.String> parameterNames,
java.lang.Object model)
Adds a DefaultMapping for every configured view BinderConfiguration.Binding for which there is an incoming request
parameter. |
protected MappingResults |
bind(java.lang.Object model)
Causes the model to be populated from information contained in request parameters. |
protected java.lang.String |
determineEventId(RequestContext context)
Obtain the user event from the current flow request. |
protected abstract void |
doRender(java.util.Map<java.lang.String,?> model)
Template method subclasses should override to execute the view rendering logic. |
protected BinderConfiguration |
getBinderConfiguration()
Returns the binding configuration that defines how to connect properties of the model to UI elements. |
protected ConversionService |
getConversionService()
|
protected java.lang.String |
getEventId()
Returns the id of the user event being processed. |
protected ExpressionParser |
getExpressionParser()
Returns the EL parser to be used for data binding purposes. |
protected java.lang.String |
getFieldMarkerPrefix()
Returns the prefix that can be used for parameters that mark potentially empty fields. |
Event |
getFlowEvent()
Get the flow event the current state should handle. |
protected MappingResults |
getMappingResults()
Returns the results of binding to the view's model, if model binding has occurred. |
protected RequestContext |
getRequestContext()
Returns the current flow request context. |
java.io.Serializable |
getUserEventState()
A memento holding the results of processing a user event. |
protected org.springframework.web.servlet.View |
getView()
Returns the Spring MVC view to render |
boolean |
hasFlowEvent()
True if a call to View.processUserEvent() raised a flow event the current state should handle. |
void |
processUserEvent()
Process the queued user event. |
void |
render()
Render this view's content. |
void |
saveState()
Saves any state associated with this view out to view scope. |
void |
setBinderConfiguration(BinderConfiguration binderConfiguration)
Sets the configuration describing how this view should bind to its model to access data for rendering. |
void |
setConversionService(ConversionService conversionService)
Sets the service to use to expose formatters for field values. |
void |
setEventIdParameterName(java.lang.String eventIdParameterName)
Sets the name of the request parameter to use to lookup user events signaled by this view. |
void |
setExpressionParser(ExpressionParser expressionParser)
Sets the expression parser to use to parse model expressions. |
void |
setFieldMarkerPrefix(java.lang.String fieldMarkerPrefix)
Specify a prefix that can be used for parameters that mark potentially empty fields, having "prefix + field" as name. |
void |
setMessageCodesResolver(org.springframework.validation.MessageCodesResolver messageCodesResolver)
Set the message codes resolver to use to resolve bind and validation failure message codes. |
void |
setValidationHintResolver(ValidationHintResolver validationHintResolver)
|
void |
setValidator(org.springframework.validation.Validator validator)
|
protected boolean |
shouldBind(java.lang.Object model,
TransitionDefinition transition)
Determines if model data binding should be invoked given the Transition that matched the current user event being processed. |
protected boolean |
shouldValidate(java.lang.Object model,
TransitionDefinition transition)
Determines if model validation should execute given the Transition that matched the current user event being processed. |
java.lang.String |
toString()
|
boolean |
userEventQueued()
True if there is a user event queued this view should process. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractMvcView(org.springframework.web.servlet.View view, RequestContext requestContext)
view
- the Spring MVC view to renderrequestContext
- the current flow request contextMethod Detail |
---|
public void setExpressionParser(ExpressionParser expressionParser)
expressionParser
- the expression parserpublic void setConversionService(ConversionService conversionService)
conversionService
- the conversion servicepublic void setValidator(org.springframework.validation.Validator validator)
public void setValidationHintResolver(ValidationHintResolver validationHintResolver)
public void setBinderConfiguration(BinderConfiguration binderConfiguration)
binderConfiguration
- the model binder configurationpublic void setMessageCodesResolver(org.springframework.validation.MessageCodesResolver messageCodesResolver)
messageCodesResolver
- the binding error message code resolver to usepublic void setFieldMarkerPrefix(java.lang.String fieldMarkerPrefix)
Default is "_", for "_FIELD" parameters (e.g. "_subscribeToNewsletter"). Set this to null if you want to turn off the empty field check completely.
HTML checkboxes only send a value when they're checked, so it is not possible to detect that a formerly checked box has just been unchecked, at least not with standard HTML means.
This auto-reset mechanism addresses this deficiency, provided that a marker parameter is sent for each checkbox field, like "_subscribeToNewsletter" for a "subscribeToNewsletter" field. As the marker parameter is sent in any case, the data binder can detect an empty field and automatically reset its value.
public void setEventIdParameterName(java.lang.String eventIdParameterName)
_eventId
eventIdParameterName
- the event id parameter namepublic void render() throws java.io.IOException
View
render
in interface View
java.io.IOException
- if an IO Exception occured rendering the viewpublic boolean userEventQueued()
View
userEventQueued
in interface View
public void processUserEvent()
View
View.userEventQueued()
returns true. After calling
this method, a flow event may be raised that should be handled in the Web Flow system.
processUserEvent
in interface View
View.hasFlowEvent()
public java.io.Serializable getUserEventState()
View
getUserEventState
in interface View
View.processUserEvent()
public boolean hasFlowEvent()
View
View.processUserEvent()
raised a flow event the current state should handle. Call
View.getFlowEvent()
to access the Event.
hasFlowEvent
in interface View
public Event getFlowEvent()
View
View.hasFlowEvent()
returns
true. Returns null
otherwise.
getFlowEvent
in interface View
null
if there is no event for the flow system to handlepublic void saveState()
View
ViewState
to allow for
any changes applied after postback processing to be captured and reflected when going back. Can be a no-op for
views that store no view state.
saveState
in interface View
public java.lang.String toString()
toString
in class java.lang.Object
protected RequestContext getRequestContext()
protected org.springframework.web.servlet.View getView()
protected ConversionService getConversionService()
protected abstract void doRender(java.util.Map<java.lang.String,?> model) throws java.lang.Exception
model
- the view model data
java.lang.Exception
- an exception occurred rendering the viewprotected java.lang.String getEventId()
protected boolean shouldBind(java.lang.Object model, TransitionDefinition transition)
bind
attribute of the Transition has been set to false.
Subclasses may override.
model
- the model data binding would be performed ontransition
- the matched transition
protected MappingResults getMappingResults()
protected BinderConfiguration getBinderConfiguration()
BinderConfiguration
or null.protected ExpressionParser getExpressionParser()
ExpressionParser
.protected java.lang.String getFieldMarkerPrefix()
protected java.lang.String determineEventId(RequestContext context)
eventIdParameterName
. Subclasses may override.
context
- the current flow request context
protected MappingResults bind(java.lang.Object model)
Causes the model to be populated from information contained in request parameters.
If a view has binding configuration then only model fields specified in the binding configuration will be considered. In the absence of binding configuration all request parameters will be used to update matching fields on the model.
model
- the model to be updated
protected void addModelBindings(DefaultMapper mapper, java.util.Set<java.lang.String> parameterNames, java.lang.Object model)
Adds a DefaultMapping
for every configured view BinderConfiguration.Binding
for which there is an incoming request
parameter. If there is no matching incoming request parameter, a special mapping is created that will set the
target field on the model to an empty value (typically null).
mapper
- the mapper to which mappings will be addedparameterNames
- the request parametersmodel
- the modelprotected void addMapping(DefaultMapper mapper, BinderConfiguration.Binding binding, java.lang.Object model)
Creates and adds a DefaultMapping
for the given BinderConfiguration.Binding
. Information such as the model field
name, if the field is required, and whether type conversion is needed will be passed on from the binding to the
mapping.
Note: with Spring 3 type conversion and formatting now in use in Web Flow, it is no longer necessary to use named converters on binding elements. The preferred approach is to register Spring 3 formatters. Named converters are supported for backwards compatibility only and will not result in use of the Spring 3 type conversion system at runtime.
mapper
- the mapper to add the mapping tobinding
- the binding elementmodel
- the modelprotected void addDefaultMappings(DefaultMapper mapper, java.util.Set<java.lang.String> parameterNames, java.lang.Object model)
DefaultMapping
instance for all incoming request parameters except those having a special field
marker prefix. This method is used when binding configuration was not specified on the view.
mapper
- the mapper to add mappings toparameterNames
- the request parameter namesmodel
- the modelprotected void addEmptyValueMapping(DefaultMapper mapper, java.lang.String field, java.lang.Object model)
DefaultMapping
that results in setting the target field on the model to an empty value
(typically null).
mapper
- the mapper to add the mapping tofield
- the field for which a mapping is to be addedmodel
- the modelprotected void addDefaultMapping(DefaultMapper mapper, java.lang.String parameter, java.lang.Object model)
DefaultMapping
between the given request parameter name and a matching model field.
mapper
- the mapper to add the mapping toparameter
- the request parameter namemodel
- the modelprotected boolean shouldValidate(java.lang.Object model, TransitionDefinition transition)
validate
attribute of the Transition has been set to false, or
model data binding errors occurred and the global validateOnBindingErrors
flag is set to false.
Subclasses may override.
model
- the model data binding would be performed ontransition
- the matched transition
|
Spring Web Flow | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |