neuland/spring-jade4j — pull request #8 by gabrielbauman (2013-06-10 02:03:24+00:00)
Title: Unpack any BindingResults in the model to a usable form

When using @ModelAttribute to mark command objects in Spring MVC, Spring injects a BindingResult object with field validation information. Unfortunately we can't access this information from Jade templates because there is no way to call object methods from Jade.

This patch is a quick pass on unpacking any BindingResult instances in the model into multiple variables.

So, for @BindingResult("objectname") the following variables would be set in the Jade model:

objectnameHasErrors, a boolean
objectnameGlobalErrors, a list of global error messages
objectnameFieldErrors, a map of fieldname => error message.

It also removes the unusable BindingResult injected by Spring.

This patch is the minimum needed to do basic form handling with Spring MVC. There are probably a bunch of corner cases that don't work, but it's a start.