org.springframework.webflow.mvc.view
Class AbstractMvcView

java.lang.Object
  extended by org.springframework.webflow.mvc.view.AbstractMvcView
All Implemented Interfaces:
View
Direct Known Subclasses:
PortletMvcView, ServletMvcView

public abstract class AbstractMvcView
extends 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
 Event getFlowEvent()
          Get the flow event the current state should handle.
 Serializable getUserEventState()
          A memento holding the results of processing a user event.
 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(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(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.
 String toString()
           
 boolean userEventQueued()
          True if there is a user event queued this view should process.
 
Methods inherited from class java.lang.Object
equals, 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

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(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(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 IOException
Description copied from interface: View
Render this view's content.

Specified by:
render in interface View
Throws:
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 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 String toString()
Overrides:
toString in class Object