I am working through the Grails in Action book and got to the part constraints in Domain Classes to introduce validation.
When I go to the “Create” form that is produced from Grails, I just clicked the “Create” button without entering any data which prompted a “Please Fill Out This Field” message.
I went in to look at the markup within FireBug and Chrome Developer tools and I saw something interesting: there are no explicit script tags (except one at the bottom for a fadein/fadeout animation). Likewise, firebug shows no changes to the dom or html markup when the message is displayed.
Documentation says that messages are shown via i18n support from Spring… but my question is: how in the world is this accomplished. Ive studied the headers and the HTML markup and I just do not see anything that would prompt the message to be displayed either by Javascript or HTML.
How is this kind of thing accomplished in web pages?
(Clarification: Grails 2.2, Firebug within Firefox, Developer tools within Chrome. i.e.: two different browsers show the same message)
The new templates in Grails 2.0+ use HTML5, so where possible client-side validation is used to avoid a server round-trip. I think it only works for blank:false though.
You will see Grails validation messages for custom validations, and standard validations that have no HTML5 analogue.