servlets struts hibernate spring maven java
 

JSF <f:validateRequired> Tag



It is utilized to guarantee that the nearby value isn't void on an EditableValueHolder component.

Tag Attributes

Attribute Description
binding It is utilized to bind a ValueExpression that evaluates to an instance of RequiredValidator.
for This attribute is used to refers to the value of one of the exposed attached objects within the composite component inside of which this tag is nested.
id It is a unique component identifier.
class It is used to represent CSS class.

JSF <f:validateRequired> Tag Example

// index.xhtml

  1. <h:form id="form">  
  2. <h:outputLabel for="username">User Name</h:outputLabel>  
  3. <h:inputText id="name-id" value="#{user.name}" validatorMessage="User name is required">  
  4. <f:validateRequired />  
  5. </h:inputText><br/>  
  6. <h:commandButton value="OK" action="response.xhtml"></h:commandButton>  
  7. </h:form>  

// User.java

  1. import javax.faces.bean.ManagedBean;  
  2. import javax.faces.bean.RequestScoped;  
  3. @ManagedBean  
  4. @RequestScoped  
  5. public class User{  
  6. String name;  
  7. public String getName() {  
  8. return name;  
  9. }  
  10. public void setName(String name) {  
  11. this.name = name;  
  12. }  
  13. }  






© Javacodegeeks © 2019 - 2019
All Right Reserved and you agree to have read and accepted our term and condition.

Python 3