This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF 2.0 View Params and (Bean) Validation for required parameter (@NotNull vs. required="true")  RSS feed

 
Thomas Tamoniczi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using view params in my templates wondering about the validation processing. The view params are mapped to a bean and its data where a property is annotated with @NotNull. But validation does NOT fail when the parameter is missing in the url or is provided without a value ("&id="). What's the logic behind that? Is the only way to set "required=true" in the definition of the view param? If this is the case I would have a redundant data definition!?
Other validations such as @Size do work properly.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"required=true" is a directive to the UI. NotNull is used by the persistence mechanism and similar items.

Technically, nothing in an HTML form can be NULL, since NULL is not a text value and HTML is all about text.
 
Thomas Tamoniczi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:"required=true" is a directive to the UI. NotNull is used by the persistence mechanism and similar items.

Technically, nothing in an HTML form can be NULL, since NULL is not a text value and HTML is all about text.


Hi Tim,

I don't understand your answer. NotNull is part of BeanValidation which can be used together along with JSF 2.0. As I have mentioned the BV-annotation Size for example is properly checked. I'm not talking about a form but about view params which seem to behave differently compared to an input field where NotNull is checked (I had a look into the code of UIViewParameter and UIInput).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!