File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF and Mysql connectivity giving error

 
Waqar Azam
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Experts i am new to JSF, and i am creating a simple database access which just simply prints the database table on the page ... but i cannot access my manged bean class in my jsf page... everytime i run the code the error it shows is {/index.xhtml @12,71 value="#{cityController.allCity}": Target Unreachable, identifier 'cityController' resolved to null} i am attaching my code please have a look at it
CityBean.java


Dbase.java


CityController.java


index.xhtml
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Waqar!

In JSF, you do not normally code Controllers. The Controller part of JSF is the FacesServlet and the support code that implements the various View Template Language elements.

Your NullPointerException comes from naming your CityController (which is actually a Model) with the name "CityController". If you must call it a Controller, call it "cityController" as required by both POJO coding conventions and because that's what your View Template is calling it.

You'll still fail, however, because you have no property access methods. So the EL reference to property "allCity" will not resolve.
 
Waqar Azam
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Welcome to the JavaRanch, Waqar!

In JSF, you do not normally code Controllers. The Controller part of JSF is the FacesServlet and the support code that implements the various View Template Language elements.

Your NullPointerException comes from naming your CityController (which is actually a Model) with the name "CityController". If you must call it a Controller, call it "cityController" as required by both POJO coding conventions and because that's what your View Template is calling it.

You'll still fail, however, because you have no property access methods. So the EL reference to property "allCity" will not resolve.


Thanks Tim for giving your time... but i very new to JSF .. would you like elaborate your answer further.... should i rename my "CityController" or what??
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should study up on JavaBeans and POJOs. JSF is based on them, as are many other popular Java technologies.

Until you understand how they work, you can't really understand how JSF works.

What you name the bean isn't really important to JSF, but, as I said, in JSF, you almost never write your own Controller code, so it's not really correct to name a bean "xxxxController". The software won't care, but it mis-informs people reading the code.
 
Waqar Azam
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:You should study up on JavaBeans and POJOs. JSF is based on them, as are many other popular Java technologies.

Until you understand how they work, you can't really understand how JSF works.

What you name the bean isn't really important to JSF, but, as I said, in JSF, you almost never write your own Controller code, so it's not really correct to name a bean "xxxxController". The software won't care, but it mis-informs people reading the code.


thanks for the advise ... i will try to follow your advice....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic