- Java EE 8 Application Development
- David R. Heffelfinger
- 226字
- 2021-07-02 22:05:00
Validation
Notice that each <h:inputField> tag has a nested <f:validateLength> tag. As its name implies, this tag validates that the entered value for the text field is between a minimum and maximum length. Minimum and maximum values are defined by the tag's minimum and maximum attributes. <f:validateLength> is one of the standard validators included with JSF. Just like with the required attribute of <h:inputText>, JSF will automatically display a default error message when a user attempts to submit a form with a value that does not validate:
Again, the default message and style can be overridden; we will cover how to do this later in the chapter.
In addition to <f:validateLength>, JSF includes other standard validators, which are listed in the following table:

Notice that in the description for <f:validateBean>, we briefly mentioned bean validation. The bean validation JSR aims to standardize JavaBean validation. JavaBeans are used across several other APIs that, up until recently, had to implement their own validation logic. JSF 2.0 adopted the bean validation standard to help validate named bean properties.
If we want to take advantage of bean validation, all we need to do is annotate the desired field with the appropriate bean validation annotation, without having to explicitly use a JSF validator.
For a complete list of bean validation annotations, refer to the javax.validation.constraints package in the Java EE 8 API at https://javaee.github.io/javaee-spec/javadocs/.
- Go語言高效編程:原理、可觀測性與優(yōu)化
- Oracle Database In-Memory(架構(gòu)與實(shí)踐)
- 構(gòu)建移動(dòng)網(wǎng)站與APP:HTML 5移動(dòng)開發(fā)入門與實(shí)戰(zhàn)(跨平臺(tái)移動(dòng)開發(fā)叢書)
- FFmpeg入門詳解:音視頻流媒體播放器原理及應(yīng)用
- C語言最佳實(shí)踐
- JavaScript前端開發(fā)與實(shí)例教程(微課視頻版)
- Learning Apache Mahout Classification
- KnockoutJS Starter
- Elasticsearch Server(Third Edition)
- SQL Server 2008 R2數(shù)據(jù)庫技術(shù)及應(yīng)用(第3版)
- C++ Application Development with Code:Blocks
- 算法超簡單:趣味游戲帶你輕松入門與實(shí)踐
- INSTANT PLC Programming with RSLogix 5000
- Android熱門應(yīng)用開發(fā)詳解
- Pandas入門與實(shí)戰(zhàn)應(yīng)用:基于Python的數(shù)據(jù)分析與處理