tags:

views:

21

answers:

1

Hi,

How can I get a single error message from a command object in grails?

all the examples I see are using similar to commandObject.errors.allErrors() but nothing if I only want the single error message to read into the controller and subsequently passed to the view.

Any ideas?

A: 

I'm not sure what "single" error you want to retrieve (for a single field?), but just wanted to point out that commandObject.errors is of type org.springframework.validation.Errors, so just have a look at the methods declared in this interface. There are methods to get the field errors, global errors etc. If you could clarify your question, we can perhaps provide a more detailed answer..

Daniel Rinser