Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
998 views
in Technique[技术] by (71.8m points)

jsf - Difference between UIInput#getValue() and getLocalValue() during validation

I would like to have an illustrative explanation about the difference between getValue() and getLocalValue() methods of UIInput components in the aspect of performing multiple field validation: jsf validate two fields in one time.

What is the difference in usage of this methods if the fields are already validated? The ValueHolder API documentation is not very helpful in answering this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If the UIInput component has been validated beforehand and is marked invalid (i.e. isValid() method returns false), then the getLocalValue() returns null, but the getValue() returns the old model value, if any. If it's marked valid, then both returns the same value, namely the submitted, converted and validated value.

You'd like to add a check on isValid() beforehand. You may find the source code examples of the OmniFaces multiple field validators helpful. See the ValidateMultipleFields source code link at the bottom of the <o:validateEqual> showcase page.

See also:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...