vineri, 20 februarie 2015

[OmniFaces utilities (2.0)] Get whether the given editable value holder component has a submitted value


[OmniFaces utilities] The hasSubmittedValue() method returns whether the given editable value holder component has a submitted value.

Method:
As you can see an empty value is considered a null value or an empty string.

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");
boolean hasSubmittedValue = Components.hasSubmittedValue(uiinput);

If you follow a simple postback scenario then the above method will return the results from figure below for non-empty submitted value:

Niciun comentariu:

Trimiteți un comentariu