Class MvcViewFactoryCreator

java.lang.Object
org.springframework.webflow.mvc.builder.MvcViewFactoryCreator
All Implemented Interfaces:
ViewFactoryCreator

public class MvcViewFactoryCreator extends Object implements ViewFactoryCreator
Returns 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 Details

  • Method Details

    • setDefaultViewSuffix

      public void setDefaultViewSuffix(String defaultViewSuffix)
      Configure an FlowResourceFlowViewResolver capable of resolving view resources by applying the specified default resource suffix. Default is .jsp.
      Parameters:
      defaultViewSuffix - the default view suffix
    • setEventIdParameterName

      public void setEventIdParameterName(String eventIdParameterName)
      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

      public void setFieldMarkerPrefix(String fieldMarkerPrefix)
      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's 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.
      Parameters:
      useSpringBeanBinding - the Spring bean binding flag
    • setFlowViewResolver

      public void setFlowViewResolver(FlowViewResolver flowViewResolver)
      Set to fully customize how the flow system resolves Spring MVC View objects.
      Parameters:
      flowViewResolver - the flow view resolver
    • setViewResolvers

      public void setViewResolvers(List<org.springframework.web.servlet.ViewResolver> viewResolvers)
      Sets the chain of Spring MVC 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.
      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 a DefaultMessageCodesResolver 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 creating View objects that can render the view template with the provided identifier.
      Specified by:
      createViewFactory in interface ViewFactoryCreator
      Parameters:
      viewId - an expression that resolves the id of the view to render
      expressionParser - an optional expression parser to use to resolve view expressions
      conversionService - an optional conversion service to use to format text values
      binderConfiguration - information on how the rendered view binds to a model that provides its data
      validator - a global validator to invoke
      validationHintResolver - 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

      public String getViewIdByConvention(String viewStateId)
      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 interface ViewFactoryCreator
      Parameters:
      viewStateId - the view state id
      Returns:
      the default view id