Class MvcViewFactoryCreator
- All Implemented Interfaces:
ViewFactoryCreator
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.
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
.
- Author:
- Keith Donald, Scott Andrews
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractMvcViewFactory
createMvcViewFactory
(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration) Creates a concrete instance of an AbstractMvcViewFactory.createViewFactory
(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration, org.springframework.validation.Validator validator, ValidationHintResolver validationHintResolver) Create a view factory capable of creatingView
objects that can render the view template with the provided identifier.getViewIdByConvention
(String viewStateId) Get the default id of the view to render in the provided view state by convention.void
setDefaultViewSuffix
(String defaultViewSuffix) Configure anFlowResourceFlowViewResolver
capable of resolving view resources by applying the specified default resource suffix.void
setEventIdParameterName
(String eventIdParameterName) Sets the name of the request parameter to use to lookup user events signaled by views created in this factory.void
setFieldMarkerPrefix
(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 MVCView
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'sBeanWrapper
should be enabled.void
setViewResolvers
(List<org.springframework.web.servlet.ViewResolver> viewResolvers) Sets the chain of Spring MVCview resolvers
to delegate to resolve views selected by flows.
-
Constructor Details
-
MvcViewFactoryCreator
public MvcViewFactoryCreator()Create a new Spring MVC View Factory Creator.
-
-
Method Details
-
setDefaultViewSuffix
Configure anFlowResourceFlowViewResolver
capable of resolving view resources by applying the specified default resource suffix. Default is .jsp.- Parameters:
defaultViewSuffix
- the default view suffix
-
setEventIdParameterName
Sets the name of the request parameter to use to lookup user events signaled by views created in this factory. If not specified, the default is_eventId
- Parameters:
eventIdParameterName
- the event id parameter name
-
setFieldMarkerPrefix
Specify a prefix that can be used for parameters that mark potentially empty fields, having "prefix + field" as name. Such a marker parameter is checked by existence: You can send any value for it, for example "visible". This is particularly useful for HTML checkboxes and select options.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.
-
setUseSpringBeanBinding
public void setUseSpringBeanBinding(boolean useSpringBeanBinding) Sets whether to use data binding with Spring'sBeanWrapper
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.- Parameters:
useSpringBeanBinding
- the Spring bean binding flag
-
setFlowViewResolver
Set to fully customize how the flow system resolves Spring MVCView
objects.- Parameters:
flowViewResolver
- the flow view resolver
-
setViewResolvers
Sets the chain of Spring MVCview 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.- Parameters:
viewResolvers
- the view resolver list
-
setMessageCodesResolver
public void setMessageCodesResolver(org.springframework.validation.MessageCodesResolver messageCodesResolver) Sets the message codes resolver strategy to use to resolve bind and validation error message codes. If not set,WebFlowMessageCodesResolver
is the default. Plug in aDefaultMessageCodesResolver
to resolve message codes consistently between Spring MVC Controllers and Web Flow.- Parameters:
messageCodesResolver
- the message codes resolver
-
createViewFactory
public ViewFactory createViewFactory(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration, org.springframework.validation.Validator validator, ValidationHintResolver validationHintResolver) Description copied from interface:ViewFactoryCreator
Create a view factory capable of creatingView
objects that can render the view template with the provided identifier.- Specified by:
createViewFactory
in interfaceViewFactoryCreator
- Parameters:
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 invokevalidationHintResolver
- a custom ValidationHintResolver to use- Returns:
- the view factory
-
createMvcViewFactory
protected AbstractMvcViewFactory createMvcViewFactory(Expression viewId, ExpressionParser expressionParser, ConversionService conversionService, BinderConfiguration binderConfiguration) Creates a concrete instance of an AbstractMvcViewFactory. -
getViewIdByConvention
Description copied from interface:ViewFactoryCreator
Get the default id of the view to render in the provided view state by convention.- Specified by:
getViewIdByConvention
in interfaceViewFactoryCreator
- Parameters:
viewStateId
- the view state id- Returns:
- the default view id
-