JSF Configure problem


Web tier: servlets, JSP, Web frameworks: JSF Configure problem

  1. JSF Configure problem (2 messages)

    i am developing a web application using Java server faces, i have some question :

    i configure a managed bean in faces-fconfig.xml file as follow:

     testBean is a property of the class NameBean, it is a client class demo.TestBean. in order to refereced the testBean objecet, i configure a referenced bean in faces-config.xml
     as follow:

    <referenced-bean> <referenced-bean-name>testBean</referenced-bean-name>
    my NameBean's code is
    public class NameBean {
    private String userName;

    private TestBean testBean;

    * @return User Name
    public String getUserName() {
    return userName;

    * @param User
    * Name
    public void setUserName(String name) {
    userName = name;

    public String login() {
    FacesContext context = FacesContext.getCurrentInstance();

    Application application = context.getApplication();

    TestBean testBean = (TestBean) application.createValueBinding(

    return "greeting";

    public TestBean getTestBean() {
    return testBean;

    public void setTestBean(TestBean testBean) {
    this.testBean = testBean;


    the TestBean code as follow:
    public class TestBean implements Serializable {
    private String loginName = "willow";

    public TestBean() {


    public String getLoginName() {
    return loginName;

    public void setLoginName(String loginName) {
    this.loginName = loginName;

    but when i excute in NameBean's login Method, i want to get the refrence of TestBean by follow code:
    TestBean testBean = (TestBean) application.createValueBinding(

    but i got testBean is null, i have configure referenced bean in faces-config.xml file,
    <referenced-bean> <referenced-bean-name>testBean</referenced-bean-name> <referenced-bean-class>demo.TestBean</referenced-bean-class
    why testBean is null? what's the problem?

    Threaded Messages (2)

  2. JSF Configure problem[ Go to top ]

    <referenced-bean> indicates that the object will be created externally from JSF and is not managed by JSF. As such getting a value binding to it would not force an instance of demo.TestBean to get created.
    If you change that to be a <managed-bean> then it will be implictly be created when any EL referrs to it.
  3. JSF Configure problem[ Go to top ]

    Also remember that when you set up dependencies between managed beans which is what you'll have here, they can't be interdependent on each other. Cyclical dependencies are not supported by JSF's managed bean facility.