[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.
Method:
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).
Usage:
JSF Page
<h:form
id="myForm">
<h:inputText id="nameId"
value="..."/>
...
</h:form>
Programmatically:
import
org.omnifaces.util.Components;
...
UIInput uiinput =
(UIInput)Faces.getViewRoot().findComponent("myForm:nameId");
String uiInputImmediateValue =
Components.getImmediateValue(uiinput);
Niciun comentariu :
Trimiteți un comentariu