• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The class '...' does not have the property '...'.

 
Marius Schmidt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'm searching for a while for a solution for the named Problem. But I didn't see a working solution for my Problem in other topics.
I am writing an JSF-Application using beans which are getting some Informations from a MySQL Database. But I have a problem getting these inormation, to the JSF-File.
Now the problem. I've got a xHtml-File ("index.xhtml") that just contains 2 inputTexts for setting an email and a Password. This seems to work. Because they could be shown at the next site ("Profil.xhtml") before. But now if I press the submit-Button the Browser shows this Error-Massage:
/Profil.xhtml @14,55 value="#{Benutzerdaten.Email}": The class 'Alumni.BeanBenutzerdaten' does not have the property 'Email'

My index.xhtml looks like this:



The site ("Profile.xhtml") that should show a Profile or something like that looks like this:



The important things of the Bean Benutzerdaten:



The get- and set-Methods are available for all Member-Variables.
The Class DAOBenutzerdaten shouldn't be the Problem because it worked in another application. The method readProfile() just reads the informations from Database and uses the set-Methods to save them to the bean.
I Hope the german words don't confuse you, but hope for help. Thank you for this. OneManArmy
 
Matthew Brown
Bartender
Posts: 4566
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marius. Welcome to the Ranch!

I'm not certain it's causing the error, but the one thing that stands out is that according to the JavaBean conventions I think you should be referring to Benutzerdaten.email - note the case of the property name, and compare it to the way you're using Password.
 
Marius Schmidt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. It works thank you. But then just one more question. Till now I thought, I have to write the name of the member variable. But what do I have to look for, for naming them right all the time? That's why I wrote it with a big Capital in JSF.
 
Matthew Brown
Bartender
Posts: 4566
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to follow the JavaBeans conventions. These are good practice in general for programming Java, but they become more important in JSF (or JSP) because they assume you are following them. That means that you use properties using lower-case in the JSF file, and the class needs to use getters and setters. So you should follow a pattern something like this:

which gives you a JavaBean property email.
 
Marius Schmidt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Thank you all.
In this case i start writing variables small, so the mistake shouldn't come again :p
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The capitalization rules for JSF are actually the capitalization rules for JavaBeans. Instance and property names begin lower-case, classnames begin uppercase. JSF will tolerate violations of these rules, but since it is assuming you are doing things properly, occasionally violators may experience unexpected problems.

Incidentally, "get" is not a good name prefix to use for an action method because it makes an executable function superficially appear to be a property retrieval method. I use "do" myself, although that's just a personal quirk.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic