Announcement Announcement Module
Collapse
No announcement yet.
Business validation error messages Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Business validation error messages

    I am a newbie to Spring and WebFlow. I want to display error messages to the user for business validations (like "no objects found for supplied criteria"). I understand the form bindandvalidate method of the FormAction, but how can I get access to the Errors object inside by business object??

    Thanks.

  • #2
    I don't know much about Spring Web Flow yet, but if it were just the SimpleFormController, in your SFC.onBindAndValidate() override you can do additional validation by accessing your service layer/business tier, and if errors such "no objects found for supplied criteria" are determined, you can call errors.rejectValue() within this oBAV() method, adding your error message to the Errors object for this command bean.

    I doubt you would want to pass in your Errors object to your service layer, probably best to keep that at the presentation layer only.

    Glen

    Comment


    • #3
      You can do syntactic validation as part of a FormAction.bindAndValidate. Then you execute a 'processSubmit' like method on your FormAction to invoke a business layer operation, that method can catch business exceptions or handle service-layer return values, making a call to 'getFormErrors(context).reject(...)' as necessary.

      Keith

      Comment


      • #4
        Thanks Keith and Glen.

        I followed the advice from Keith and added a processSubmit method for the FormAction which is called instead of calling the BO directly. Now I can use the errors object.

        Comment

        Working...
        X