-1

I m using netbeans 7.2.1 as IDE. I m trying to develop an Multiple Questions Choices web app with various users profile, based on JSF framework and running on GLASSFISH3+ server, and i had problem when introducing a fourth managed bean. So i made a test with another project, using 4 managed bean with the same code, and having a simple string attribute. testBean, test2Bean, test3Bean, test4Bean. Here is the sample code:


import javax.faces.bean.ManagedBean; 
import javax.faces.bean.SessionScoped;
@ManagedBean 
@SessionScoped 
public class test3Bean implements java.io.Serializable {
private String s;
public String getS() { 
return s; 
} 
public void setS(String s) {
this.s = s; 
}
} 

The web app has a simple index.xhtml reading 4 input to be set to the 4 managed bean: index.xhtml


Enter testword 1 h:inputText value="#{test1.S}
Enter testword 2 h:inputText value="#{test2.S}
Enter testword 3 h:inputText value="#{test3.S}
Enter testword 4 h:inputText value="#{test4.S}

   A submit button

the reponse.xhtml would show the 4 inputs.

When running the application the undex.xhtml show up and after i entred words on h:inputText and submitting i have this error:

/index.xhtml @14,107 value="#{test4.s}": Target Unreachable, identifier 'test4' resolved to null.

I dont understand with the same code testBean 1,2, and 3 has been processed by Mojarra/faclets engine and not test4Bean.

ANY Idea please.

JiTHiN
  • 6,548
  • 5
  • 43
  • 69
Karbon14
  • 1
  • 1
  • 1
    With this code of bean it should be something like `test4Bean.s`? And you should name your classes with first uppercase. – partlov Mar 06 '13 at 10:56

1 Answers1

1

Your code is somewhat confusing. First you should write all your class names with the first letter uppercase:

import javax.faces.bean.ManagedBean; 
import javax.faces.bean.SessionScoped;
@ManagedBean 
@SessionScoped 
public class Test3Bean implements java.io.Serializable {
  ..
}

This bean must be called from your views with the identifier test3Bean (notice that the first letter is now lowercase). The bean property must be lowercase as well.

With this a correct input field in JSF would look like:

<h:inputText value="#{test3Bean.s} />

Change your code according to these suggestions and try again.

Matt Handy
  • 29,855
  • 2
  • 89
  • 112
  • THANX MATT. I really appreciate. It works yes, but it does not explain why the Mojarra implementation has resolved test1, test2, and tes3 Beans and not test 4 Bean. !!!!!!!!!!!!. – Karbon14 Mar 08 '13 at 07:31
  • Maybe something else with your project set-up. I am work with JSF for 3 years now and never had similar problems. Hard to tell. – Matt Handy Mar 08 '13 at 08:39