servlets struts hibernate spring maven java
 

JSF <f:validateLength> Tag



It is utilized to check whether the length of a component's value is inside a specific range or not. The value must be a java.lang.String.

Tag Attributes

Attribute Description
minimum It is utilized to set least length for the component.
maximum It is utilized to set most extreme length for the component.

// index.xhtml

  1. <h:form id="user-form">  
  2. <h:outputLabel for="name">User Name</h:outputLabel><br/>  
  3. <h:inputText id="user-name" value="#{user.name}">  
  4. <f:validateLength  minimum="5"  maximum="10"/>  
  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. import javax.validation.constraints.NotNull;  
  4. @ManagedBean  
  5. @RequestScoped  
  6. public class User{  
  7. @NotNull  
  8. String name;  
  9. public String getName() {  
  10. return name;  
  11. }  
  12. public void setName(String name) {  
  13. this.name = name;  
  14. }  
  15. }  






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

Python 3