public class MvcViewFactoryCreator extends java.lang.Object implements ViewFactoryCreator, org.springframework.context.ApplicationContextAware
view factories
that create native Spring MVC-based views. Used by a FlowBuilder to
configure a flow's view states with Spring MVC-based view factories.
This implementation detects whether it is running in a Servlet or Portlet MVC environment, and returns instances of the default view factory implementation for that environment.
By default, this implementation creates view factories that resolve their views by loading flow-relative resources,
such as .jsp templates located in a flow working directory. This class also supports rendering views resolved by
pre-existing Spring MVC view resolvers
.
ServletMvcViewFactory
,
PortletMvcViewFactory
,
FlowResourceFlowViewResolver
,
DelegatingFlowViewResolver
Constructor and Description |
---|
MvcViewFactoryCreator()
Create a new Spring MVC View Factory Creator.
|
Modifier and Type | Method and Description |
---|---|
protected AbstractMvcViewFactory |
createMvcViewFactory(Expression viewId,
ExpressionParser expressionParser,
ConversionService conversionService,
BinderConfiguration binderConfiguration)
Creates a concrete instance of an AbstractMvcViewFactory according to the runtime environment (Servlet or
Portlet).
|
ViewFactory |
createViewFactory(Expression viewId,
ExpressionParser expressionParser,
ConversionService conversionService,
BinderConfiguration binderConfiguration,
org.springframework.validation.Validator validator)
Create a view factory capable of creating
View objects that can render the view template with the
provided identifier. |
java.lang.String |
getViewIdByConvention(java.lang.String viewStateId)
Get the default id of the view to render in the provided view state by convention.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setDefaultViewSuffix(java.lang.String defaultViewSuffix)
Configure an
FlowResourceFlowViewResolver capable of resolving view resources by applying the specified
default resource suffix. |
void |
setEventIdParameterName(java.lang.String eventIdParameterName)
Sets the name of the request parameter to use to lookup user events signaled by views created in this factory.
|
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 |
setFlowViewResolver(FlowViewResolver flowViewResolver)
Set to fully customize how the flow system resolves Spring MVC
View objects. |
void |
setMessageCodesResolver(org.springframework.validation.MessageCodesResolver messageCodesResolver)
Sets the message codes resolver strategy to use to resolve bind and validation error message codes.
|
void |
setUseSpringBeanBinding(boolean useSpringBeanBinding)
Sets whether to use data binding with Spring's
BeanWrapper should be enabled. |
void |
setViewResolvers(java.util.List viewResolvers)
Sets the chain of Spring MVC
view resolvers to delegate to resolve views selected by flows. |
public MvcViewFactoryCreator()
public void setDefaultViewSuffix(java.lang.String defaultViewSuffix)
FlowResourceFlowViewResolver
capable of resolving view resources by applying the specified
default resource suffix. Default is .jsp.defaultViewSuffix
- the default view suffixpublic void setEventIdParameterName(java.lang.String eventIdParameterName)
_eventId
eventIdParameterName
- the event id parameter namepublic 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 setUseSpringBeanBinding(boolean useSpringBeanBinding)
BeanWrapper
should be enabled. Set to 'true' to enable.
'false', disabled, is the default. With this enabled, the same binding system used by Spring MVC 2.x is also used
in a Web Flow environment.useSpringBeanBinding
- the Spring bean binding flagpublic void setFlowViewResolver(FlowViewResolver flowViewResolver)
View
objects.flowViewResolver
- the flow view resolverpublic void setViewResolvers(java.util.List viewResolvers)
view resolvers
to delegate to resolve views selected by flows.
Allows for reuse of existing View Resolvers configured in a Spring application context. If multiple resolvers are
to be used, the resolvers should be ordered in the manner they should be applied.viewResolvers
- the view resolver listpublic void setMessageCodesResolver(org.springframework.validation.MessageCodesResolver messageCodesResolver)
WebFlowMessageCodesResolver
is the default. Plug in a DefaultMessageCodesResolver
to resolve
message codes consistently between Spring MVC Controllers and Web Flow.messageCodesResolver
- the message codes resolverpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration, org.springframework.validation.Validator validator)
ViewFactoryCreator
View
objects that can render the view template with the
provided identifier.createViewFactory
in interface ViewFactoryCreator
viewId
- an expression that resolves the id of the view to renderexpressionParser
- an optional expression parser to use to resolve view expressionsconversionService
- an optional conversion service to use to format text valuesbinderConfiguration
- information on how the rendered view binds to a model that provides its datavalidator
- a global validator to invokeprotected AbstractMvcViewFactory createMvcViewFactory(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration)
public java.lang.String getViewIdByConvention(java.lang.String viewStateId)
ViewFactoryCreator
getViewIdByConvention
in interface ViewFactoryCreator
viewStateId
- the view state id