Hi there
I'm new with spring framework. I'm currently building some news manager form.
Here a sample of my news entity :
class News
{
@NotNull
long id;
@NotNull
long idAuthor;
@Size(max=255)
String content;
}
As you can see, I use JSR303 annotation validation with Spring. I want to validate my "news edit form".
@RequestMapping( value = "/edit" , method = RequestMethod.POST)
public String editAction(@Valid @ModelAttribute News news, BindingResult result)
{
System.err.println(result.hasErrors());
...
return "editView";
}
Define allowed field :
//initBinder function :
binder.setAllowedFields("content");
Well, i'm trying to validate only "content" field (allowed field set on my binder)... But Spring always validate all the field defined on my entity (so "id" & "idAuthor" return error)
How can i only validate allowed field (set on initBinder function) ?