Expert Spring MVC and Web Flow

(Dana P.) #1

Figure 8-2.BindStatus attributes and operations


■NoteThere is a distinction between failure in binding and failure in validation. Binding occurs first, and
this can fail if your user submits a value in a field that cannot automatically be converted to the required
type, or for which a suitable PropertyEditorhas not been registered. For example, your command object
has a field of type java.util.Dateand the user enters a value of 3. Validation failure is a failure of bound
values to meet business or other validation logic that you supply yourself in the Validatorclass. Neither
binding nor validation errors are considered fatal, and they are rounded up together in the errors instance.


Nested Paths


If your forms and command objects are fairly complex, you can take advantage of the


tag to make it a little more readable. Setting a nested path affects the
bind path for all future binds within the body of the tag, prefixing the bind path with the
nested path. Path nesting can be specified multiple times.
We can best explain this by way of example. Listing 8-7 shows a form layout in a JSP that
uses several tag uses for various fields and nested fields on the command object.
BindStatus


  • requestContext : RequestContext

  • path : String

  • htmlEscape : boolean

  • expression : String

  • errors : Errors

  • editor : Property Editor

  • value : Object

  • objectErrors : List

  • errorCodes : String

  • errorMessages : String



  • BindStatus()



  • initErrorCodes()

  • initErrorMessages()



  • getPath() : String

  • getExpression() : String

  • getValue() : Object

  • getDisplay Value() : String

  • isError() : boolean

  • getErrorCodes() : String

  • getErrorCode() : String

  • getErrorMessages() : String

  • getErrorMessage() : String

  • getErrorMessagesAsString(delimiter : String) : String

  • getErrors() : Errors

  • getEditor() : Property Editor

  • toString() : String


CHAPTER 8 ■SUPPORTED VIEW TYPES 229
Free download pdf