Grails

Unexpected command object errors rendered

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2 final
  • Fix Version/s: 1.2.1, 1.3-M1
  • Component/s: Controllers
  • Labels:
    None
  • Environment:
    Ubuntu Karmic, Grails 1.2.0

Description

Trigger the following urls in the example:
/<app-name>/test/searchForm results in form being properly rendered without errors
/<app-name>/test/search results in form being rendered with errors though the command object passed via the model is not validated,
so I would expect an empty form being rendered just as in the first case

It seems that errors are always rendered if there is a command object parameter being declared in the closure independently of the actual object that is passed to the view. Complete code is given in attachment.

class TestController {

def searchForm = { render(view: 'search', model:['cmd': new SearchCommand()]) // properly renders form without error messages, expected behavior }

def search = {SearchCommand c -> if(!params.search) return ['cmd': new SearchCommand()] // renders form with error messages, unexpected behavior ... }
}
class SearchCommand {
String zip
static constraints = { zip(nullable:false,blank:false,maxSize:5) }
}

Workaround: Separate method to render empty form.

Issue Links

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: