Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring MVC form binding #7

Open
gabrielbauman opened this issue Jun 6, 2013 · 2 comments
Open

Spring MVC form binding #7

gabrielbauman opened this issue Jun 6, 2013 · 2 comments

Comments

@gabrielbauman
Copy link
Contributor

Hi there,

Spring does some nifty form backing object binding and validation when a controller has a method like this:

public String handleForm(@ModelAttribute @Valid EmployeeForm employeeForm, BindingResult bindingResult)

I'm trying to figure out how to hook into this mechanism from a Jade template. Immediate question: how should my form input tags be named for the above controller method?

Obviously spring-jade4j doesn't have a macro library like that offered by Spring's Freemarker, Velocity, and JSP template resolvers. It seems like one could be easily implemented using Jade mixins.

@gabrielbauman
Copy link
Contributor Author

I've found that Spring inserts BindingResults instances for each @ModelAttribute into the model after the controller method runs.

The binding result including field values and validation errors can be found in the model with the key BindingResult.MODEL_KEY_PREFIX + objectName .

For the above handleForm method, that would be "org.springframework.validation.BindingResult.employeeForm".

I'm working on a small Jade mixin library to make working with this easier.

@ytoh
Copy link

ytoh commented Aug 6, 2013

Hi @gabrielbauman any luck with the mixin library?

I am working on something similar for our project.

/Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants