Showing posts with label ADF validation. Show all posts
Showing posts with label ADF validation. Show all posts

Monday 1 December 2014

Email Validation in ADF

Hello Fellas,
Today I'm sharing my learning to how to make a custom validation in Oracle JDeveloper,
Create a java class,

Lets take an example to create a e-mail validation,



import java.io.Serializable;

import java.util.regex.Matcher;
import java.util.regex.Pattern;import javax.faces.application.FacesMessage;import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class EmailValidator implements Serializable, Validator {

    public EmailValidator() {
        super();
    }
    public void validate(FacesContext facesContext, UIComponent uiComponent,
                         Object object) {
        String value = (String)object;
        if ((value == null) || value.length() == 0) {
            System.out.println("null value found");
            return;
            //System.out.println("null value found");
        }
        //String expression="^[\\\\w\\\\-]([\\\\.\\\\w])+[\\\\w]+@([\\\\w\\\\-]+\\\\.)+[A-Z]{2,4}$";
        String expression =
            "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
        CharSequence inputstr = value;
        Pattern pattern =
            Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(inputstr);
        if (!matcher.matches()) {
            throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                                          "Enter the proper Email Id",
                                                          null));
        }
    }
}





Go to faces-config.xml and open validators tab give a meaningful Id like EmailValidator
& class name
in this case it should be EmailValidator(along with the package)

in the input file just write
<af:inputText label="Enter EmailID" id="it1">
<f:validator validatorid="EmailValidator"/>
</af:inputText>


thank you :)

A Guide to Installing Oracle HR Schema on an Existing Docker Container

  Hi Reader, Today I want to share my learning on how to install Oracle HR schema on a existing docker container. Step 1: Download the verif...