Get the JSF value binding - Java JSF

Java examples for JSF:Application

Description

Get the JSF value binding

Demo Code


import javax.faces.el.ValueBinding;
import javax.faces.application.ApplicationFactory;
import javax.faces.application.Application;
import javax.faces.FactoryFinder;
import javax.faces.context.FacesContext;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;

public class Main{
    public static void main(String[] argv) throws Exception{
        String valueRef = "java2s.com";
        System.out.println(getValueBinding(valueRef));
    }//  w  ww .  jav a  2s.c  om
    /**
     * Get the JSF value binding
     *
     * @param valueRef value reference
     * @return Value binding object
     */
    private static ValueBinding getValueBinding(String valueRef) {
        ApplicationFactory factory = (ApplicationFactory) FactoryFinder
                .getFactory(FactoryFinder.APPLICATION_FACTORY);
        Application application = factory.getApplication();
        return application.createValueBinding(valueRef);
    }
}

Related Tutorials