JSF and Mysql connectivity giving error

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

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.

Customer surveys are for companies who didn't pay proper attention to begin with.

Waqar Azam
Greenhorn

Joined: Feb 27, 2013
Posts: 6

posted Feb 28, 2013 06:46:44

0

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??

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

Joined: Feb 27, 2013
Posts: 6

posted Mar 01, 2013 08:17:38

0

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.