apache / apache/grails-core

Automatically render a view if command object has errors

Open
#603 5 comments 0 reactions 0 assignees View on GitHub
status: acknowledged type: enhancement type: improvement
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

It is based on discussion with JeffScottBrown on this thread
http://stackoverflow.com/questions/24742294/refactoring-grails-command-validation

Basically, most of the actions which accepts command objects do some thing like this

``` groovy
def add(CreatePersonCommand command) {
if(command.hasErrors()) {
redirect(action: 'add')
return
}
}
```

It would be great if there was a built in support in grails to render a view if command object has errors
Some thing like this

``` groovy
@Validate(view:"someView")
def add(CreatePersonCommand command) {

}
```

Contributor guide

Open the contributing guide

Research direction

Start with the `add(CreatePersonCommand command)` action shown in the issue and the proposed `@Validate(view:"someView")` entry point. Trace how Grails actions handle command-object validation errors, then define and test the automatic view-rendering behavior for invalid commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.