Accessing Managed Bean methods programmatically in JSF 1.1

Access Managed Bean methods

As we know JSF managed beans are mostly access only through the JSP pages are faces-config.xml.But, there is some schenarios where you will need information stored in the managed beans for the business logic in some other beans. JSF provides API to access those values where ever you want.

also read:

Note that this example uses JSF 1.1 technique for accessing the values. These APIs are deprecated in JSF 1.2 and there is new APIs available from JSF 1.2 verion. The following sample programs use the normal programming API tp get the managed bean stored in the session and trying to invoke methods and properties.

JSP File (index.jsp)

<%@taglib prefix="f" uri=""%>
<%@taglib prefix="h" uri=""%>
                <h:commandButton action="#{jsfBean.submit}" value="Submit"/>

JavaBean (


import java.util.List;
import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;

 * source :
public class JavaBeatJsfBean {
    private List listValues;

    public List getListValues() {
        return listValues;

    public void setListValues(List listValues) {
        this.listValues = listValues;
    public String submit(){
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application application = facesContext.getApplication();
        ValueBinding binding = application.createValueBinding("#{userInfo}");
        UserInfo userInfo = (UserInfo)binding.getValue(facesContext);
        System.out.println("Method Calling : "+userInfo.getValuesNoArg());
        System.out.println("User Name : "+userInfo.getUserName());
        return "success";


 * source :
public class UserInfo {
    private String userName;

    public String getUserName() {
        return userName;

    public void setUserName(String userName) {
        this.userName = userName;

    public String getValuesNoArg(){
        return "NoArgs";


<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2"

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!