Never mind, I'm an idiot. I put the SaveUserCommand.groovy file in the wrong project. Doh!
Thanks anyways.
Pam
-----Original Message-----
From: Callaway, Pamela [mailto:
pcallaway@...]
Sent: Friday, May 16, 2008 3:48 PM
To:
user@...
Subject: RE: [grails-user] hasErrors question
Hi, folks. I ended up using the Command object because the field was not a field in my class (ie confirmation password).
The documentation says that command objects can be in the controllers directory, so I put mine there. However, the compiler tells me it can't find the object. Is there something I'm doing wrong?
Code:
def save = { SaveUserCommand cmd ->
if(cmd.hasErrors()){
redirect(action:'create')
}
Error:
[groovyc] Compiling 2 source files to C:\Documents and Settings\hbsuser\.grails\1.0.2\projects\simpleSecurity\classes
Compilation error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, C:\code\simpleSecurity\grails-app\controllers\JsecUserController.groovy: 112: unable to resolve class SaveCommand
@ line 112, column 14.
def save = { SaveCommand cmd ->
^
C:\code\simpleSecurity\grails-app\controllers\JsecUserController.groovy: 113: unable to resolve class SaveCommand
@ line 113, column 9.
if(cmd.hasErrors()){
^
Thanks!
Pam
-----Original Message-----
From: Callaway, Pamela [mailto:
pcallaway@...]
Sent: Friday, May 16, 2008 11:46 AM
To:
user@...
Subject: RE: [grails-user] hasErrors question
That's exactly what I was looking for. The Command object looks promising, too - that's the first time I've heard of it, but it looks designed for exactly what I'm doing.
Thanks!
Pam
-----Original Message-----
From: Peter Ledbrook [mailto:
peter@...]
Sent: Friday, May 16, 2008 2:50 AM
To:
user@...
Subject: Re: [grails-user] hasErrors question
> My question is about hasErrors... I can see in the generated controller where
> it will call hasErrors() on an object. How do I set errors like that? I
> tried obj.hasErrors = true, but that didn't work. I don't know what to
> search for, so I can't find any documentation besides what the tag hasErrors
> does...
See the "reject()" and "rejectValue()" methods in the Errors interface:
http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/validation/Errors.html"rejectValue()" is probably the one you want.
Cheers,
Peter
--
Software Engineer
G2One, Inc.
http://www.g2one.com/---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email