This is not complex to use validator in ADF forms. Suppose we have a field of EmailId on form and we want to add custom email validator on this field
To add validator in a field follow these steps
- Select the field in Form
- Now go to property inspector and Select Validator,it is empty by default
- Now click on Validator edit in property inspector and create a validator in ManagedBean of taskflow
- It will look like this- Default Custom Validator
- Now we will add custom code to validate EmailId field in this validator
- if(object!=null){
- String expression="^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
- CharSequence inputStr=name;
- if(matcher.matches()){
- }
- else{
- throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,msg,null));
- }
- }
- }
- Now when we run this page, we can see validation
No comments:
Post a Comment