Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.webflow.mvc.view
Class AbstractMvcView

    java.lang.Object
      org.springframework.webflow.mvc.view.AbstractMvcView

All Implemented Interfaces:
  View

Direct Known Subclasses:
  PortletMvcView, ServletMvcView

    public abstract class AbstractMvcView

extends java.lang.Object
implements View

Base view implementation for the Spring Web MVC Servlet and Spring Web MVC Portlet frameworks.

Author:
  Keith Donald

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 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 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 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` | `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

### AbstractMvcView

    public AbstractMvcView(org.springframework.web.servlet.View view,
                           RequestContext requestContext)

  Creates a new MVC view.

  Parameters:
    `view` - the Spring MVC view to render
    `requestContext` - the current flow request context

Method Detail

### setExpressionParser

    public void setExpressionParser(ExpressionParser expressionParser)

  Sets the expression parser to use to parse model expressions.

  Parameters:
    `expressionParser` - the expression parser

### setConversionService

    public void setConversionService(ConversionService conversionService)

  Sets the service to use to expose formatters for field values.

  Parameters:
    `conversionService` - the conversion service

### setValidator

    public void setValidator(org.springframework.validation.Validator validator)

### setBinderConfiguration

    public void setBinderConfiguration(BinderConfiguration binderConfiguration)

  Sets the configuration describing how this view should bind to its model to access data for rendering.

  Parameters:
    `binderConfiguration` - the model binder configuration

### setMessageCodesResolver

    public void setMessageCodesResolver(org.springframework.validation.MessageCodesResolver messageCodesResolver)

  Set the message codes resolver to use to resolve bind and validation failure message codes.

  Parameters:
    `messageCodesResolver` - the binding error message code resolver to use

### setFieldMarkerPrefix

    public 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. 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.

### setEventIdParameterName

    public void setEventIdParameterName(java.lang.String eventIdParameterName)

  Sets the name of the request parameter to use to lookup user events signaled by this view. If not specified, the default is `_eventId`

  Parameters:
    `eventIdParameterName` - the event id parameter name

### render

    public void render()
                throws java.io.IOException

  Description copied from interface: `View`
  Render this view's content.

  Specified by:
    `render` in interface `View`
  Throws:
    `java.io.IOException` - if an IO Exception occured rendering the view

### userEventQueued

    public boolean userEventQueued()

  Description copied from interface: `View`
  True if there is a user event queued this view should process.

  Specified by:
    `userEventQueued` in interface `View`
  Returns:
    true if a user event is queued, false if not

### processUserEvent

    public void processUserEvent()

  Description copied from interface: `View`
  Process the queued user event. Should only be called when `View.userEventQueued()` returns true. After calling this method, a flow event may be raised that should be handled in the Web Flow system.

  Specified by:
    `processUserEvent` in interface `View`
  See Also:
    `View.hasFlowEvent()`

### getUserEventState

    public java.io.Serializable getUserEventState()

  Description copied from interface: `View`
  A memento holding the results of processing a user event. Used to allow transient view state such as binding and validation errors to survive a flow execution redirect.

  Specified by:
    `getUserEventState` in interface `View`
  Returns:
    the serializable user event state object, or null if no event state needs managing
  See Also:
    `View.processUserEvent()`

### hasFlowEvent

    public boolean hasFlowEvent()

  Description copied from interface: `View`
  True if a call to `View.processUserEvent()` raised a flow event the current state should handle. Call `View.getFlowEvent()` to access the Event.

  Specified by:
    `hasFlowEvent` in interface `View`
  Returns:
    true if yes, false otherwise

### getFlowEvent

    public Event getFlowEvent()

  Description copied from interface: `View`
  Get the flow event the current state should handle. Returns an Event object when `View.hasFlowEvent()` returns true. Returns `null` otherwise.

  Specified by:
    `getFlowEvent` in interface `View`
  Returns:
    the event, or `null` if there is no event for the flow system to handle

### saveState

    public void saveState()

  Description copied from interface: `View`
  Saves any state associated with this view out to view scope. Called when exiting a `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.

  Specified by:
    `saveState` in interface `View`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getRequestContext

    protected RequestContext getRequestContext()

  Returns the current flow request context.

  Returns:
    the flow request context

### getView

    protected org.springframework.web.servlet.View getView()

  Returns the Spring MVC view to render

  Returns:
    the view

### getConversionService

    protected ConversionService getConversionService()

  Returns:
    the configured ConversionService

### doRender

    protected abstract void doRender(java.util.Map model)
                              throws java.lang.Exception

  Template method subclasses should override to execute the view rendering logic.

  Parameters:
    `model` - the view model data
  Throws:
    `java.lang.Exception` - an exception occurred rendering the view

### getEventId

    protected java.lang.String getEventId()

  Returns the id of the user event being processed.

  Returns:
    the user event

### shouldBind

    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. Returns true unless the `bind` attribute of the Transition has been set to false. Subclasses may override.

  Parameters:
    `model` - the model data binding would be performed on
    `transition` - the matched transition
  Returns:
    true if binding should occur, false if not

### getMappingResults

    protected MappingResults getMappingResults()

  Returns the results of binding to the view's model, if model binding has occurred.

  Returns:
    the binding (mapping) results

### getBinderConfiguration

    protected BinderConfiguration getBinderConfiguration()

  Returns the binding configuration that defines how to connect properties of the model to UI elements.

  Returns:
    an instance of `BinderConfiguration` or null.

### getExpressionParser

    protected ExpressionParser getExpressionParser()

  Returns the EL parser to be used for data binding purposes.

  Returns:
    an instance of `ExpressionParser`.

### getFieldMarkerPrefix

    protected java.lang.String getFieldMarkerPrefix()

  Returns the prefix that can be used for parameters that mark potentially empty fields.

  Returns:
    the prefix value.

### determineEventId

    protected java.lang.String determineEventId(RequestContext context)

  Obtain the user event from the current flow request. The default implementation returns the value of the request parameter with name `eventIdParameterName`. Subclasses may override.

  Parameters:
    `context` - the current flow request context
  Returns:
    the user event that occurred

### bind

    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.

  Parameters:
    `model` - the model to be updated
  Returns:
    an instance of MappingResults with information about the results of the binding.

### addModelBindings

    protected void addModelBindings(DefaultMapper mapper,
                                    java.util.Set 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).

  Parameters:
    `mapper` - the mapper to which mappings will be added
    `parameterNames` - the request parameters
    `model` - the model

### addMapping

    protected 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.

  Parameters:
    `mapper` - the mapper to add the mapping to
    `binding` - the binding element
    `model` - the model

### addDefaultMappings

    protected void addDefaultMappings(DefaultMapper mapper,
                                      java.util.Set parameterNames,
                                      java.lang.Object model)

  Add a `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.

  Parameters:
    `mapper` - the mapper to add mappings to
    `parameterNames` - the request parameter names
    `model` - the model

### addEmptyValueMapping

    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).

  Parameters:
    `mapper` - the mapper to add the mapping to
    `field` - the field for which a mapping is to be added
    `model` - the model

### addDefaultMapping

    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.

  Parameters:
    `mapper` - the mapper to add the mapping to
    `parameter` - the request parameter name
    `model` - the model

### shouldValidate

    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. Returns true unless the `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.

  Parameters:
    `model` - the model data binding would be performed on
    `transition` - the matched transition
  Returns:
    true if binding should occur, false if not

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD