Announcement Announcement Module
Collapse
No announcement yet.
Displaying validation errors in Velocity templates... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Displaying validation errors in Velocity templates...

    The BindException class allows you to reject either a specific field in the command object (using "rejectValue") or the entire command object (using "reject").

    Is there a way to display validation errors pertaining to the command object, and NOT a specific field, in a velocity template? It appears as if the #springShowErrors("", "") macro only displays errors associated with a single field. Hope this is clear enough! If not, I'll be happy to post some code snippets of what I'm trying to do.

    Thanks in advance!

    Brian St.Clair

  • #2
    I would like to see some code snippets actually, I'm trying to do a similar thing!

    Comment


    • #3
      there's no Spring macro to do this at present but you can get the errors object from the requestContext and iterate over the globalErrors..

      #foreach(err in $rc.errors.globalErrors)
      ...
      #end

      You may like to raise a JIRA for the missing macro to be added as standard (assign it to me if you do)

      Regards,

      Comment


      • #4
        Here's what I've used - when my commandClass = "user"

        Code:
        #springBind("user.*")
        #if ($status.error)
        <div class="error">
            #foreach &#40;$error in $status.errorMessages&#41;
                $&#123;error&#125;<br/>
            #end
        </div>
        #end

        Comment

        Working...
        X