Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 2.0 final
-
Component/s: None
-
Labels:None
Description
If my command object uses 3 arguments custom validator, errors properties does not survive redirect:
e.g.
class FooCommand {
String bar
static constraints = {
bar(
nullable: true,
validator: { val, obj, errors ->
if (SomeLogic.check(val, obj)) {
errors.rejectValue('bar', 'errmsg', null, 'blah')
return false
}
return true
}
)
}
}
If my controller upon seeing command.hasErrors(), puts the command object somewhere, say in session, then redirect it to another controller/action, which retrieve the command object from the session, the errors properties does not report hasErrors().
Incidentally, if I use the 2 args validator form, the errors dynamic properties is retained after a redirect.
-
Hide
- grails2400.zip
- 01/Sep/11 3:18 PM
- 107 kB
- Jeff Brown
-
- grails2400/.classpath 0.7 kB
- grails2400/.gitignore 0.0 kB
- grails2400/.project 0.5 kB
- grails2400/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- grails2400/application.properties 0.1 kB
- grails2400/grails-app/.../BootStrap.groovy 0.1 kB
- grails2400/grails-app/.../BuildConfig.groovy 2 kB
- grails2400/grails-app/conf/Config.groovy 4 kB
- grails2400/grails-app/.../DataSource.groovy 0.7 kB
- grails2400/grails-app/.../UrlMappings.groovy 0.2 kB
- grails2400/grails-app/.../resources.groovy 0.0 kB
- grails2400/.../DemoController.groovy 0.4 kB
- grails2400/.../messages.properties 3 kB
- grails2400/.../messages_cs_CZ.properties 3 kB
- grails2400/.../messages_da.properties 3 kB
- grails2400/.../messages_de.properties 4 kB
- grails2400/.../messages_es.properties 3 kB
- grails2400/.../messages_fr.properties 2 kB
- grails2400/.../messages_it.properties 2 kB
- grails2400/.../messages_ja.properties 2 kB
- grails2400/.../messages_nl.properties 3 kB
- grails2400/.../messages_pt_BR.properties 3 kB
- grails2400/.../messages_pt_PT.properties 3 kB
- grails2400/.../messages_ru.properties 4 kB
- grails2400/.../messages_sv.properties 3 kB
- grails2400/.../messages_th.properties 5 kB
- grails2400/.../messages_zh_CN.properties 2 kB
- grails2400/grails-app/.../thirdAction.gsp 0.2 kB
- grails2400/grails-app/views/error.gsp 0.3 kB
- grails2400/grails-app/views/index.gsp 3 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
Hide
Jeff Brown
added a comment -
See the attached Grails 2.0.M1 project. I don't think this is a problem now that we have a real Errors property associated with validateable objects like command objects.
Show
Jeff Brown
added a comment - See the attached Grails 2.0.M1 project. I don't think this is a problem now that we have a real Errors property associated with validateable objects like command objects.
This is still an issue with Grails 1.3.6.
From my point of view this is a problem with the dynamic 'errors' property. It isn't a real object reference but is resolved via Groovy magic. Therefore the errors object of a CommandObject or DomainObject isn't stored in the Web-Session.
Workaround: Store the errors object in the session explicitly and reassign it if object is read
def beforeRedirect = { .... session.cmd = cmd session.cmd_errors = cmd.errors .... } def afterRedirect = { .... def cmd = session.cmd cmd.errors = session.cmd_errors ..... }