My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...









[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians


joi, 19 februarie 2015

[OmniFaces utilities (2.0)] Get the value of the given UIInput whereby any unconverted submitted string value will immediately be converted/validated

[OmniFaces utilities] The getImmediateValue() method returns the value of the given input component whereby any unconverted submitted string value will immediately be converted/validated as this method is called. This method thus always returns the converted/validated value.

Practically, for an UIInput, this method "forces" the conversion/validation of the submitted value and returns the result. First, it ensures that the validation didn't took place before this method is called (if UIInput#isValid() returns false then the validation took place and it failed, and if the submitted value is null then there is nothing to validate, or the validation successfully took place). If the validation didn't took place then "force" it by calling the UIInput#validate() method. If the validation successfully ends, then JSF signal this by setting the local value set state for this component as true. This means that the local value is available and the UIInput.getValue() will serve us. Otherwise, there is no local value, so return null. This method will not inhibit the JSF Process Validations phase to take place as it usually do, but don't expect to "see" to much action there (e.g. If this method is called in Apply Request Values phase, then the validation take place, the local value is set and the submitted value is reset to null. Later, in Process Validations phase, the submitted value is null, so, in the validate() method, JSF will act as the component was not submitted at all, and return immediately, so no converters/validators will be called).


JSF Page
<h:form id="myForm">
 <h:inputText id="nameId" value="..."/>

import org.omnifaces.util.Components;
UIInput  uiinput = (UIInput)Faces.getViewRoot().findComponent("myForm:nameId");
String uiInputImmediateValue = Components.getImmediateValue(uiinput);

Niciun comentariu :

Trimiteți un comentariu


Postări populare

OmniFaces/JSF Fans

Visitors Starting 4 September 2015

Locations of Site Visitors