• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in populate panelGrid.

 
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I trying to create a panelGrid with MySQL records I have an class of getters and setters and a managedbean that use this class and access mysql to load records. The problem is that the way of that I created my project the <h: outputText can't access the fields.
BEAN class:

DAO class:

How can I work with getter and setter into my DAO class? I beliave that is a solution but  can't see.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are violating the standard JavaBean conventions.

Acording to standard practice, the names of bean properties (and of variables and JSF Managed Beans) must begin with a lower-case letter. Only the names of java classes begin with an upper-case letter.

When the JSF framework invokes the bean utils to get a property value, it will convert the first character of the property name to upper case and prefix with "get" (or "is", for boolean) to get the name of the method to call.

Thus, if bean "mybean" has a property named "startTime", the get-method call is "getStartTime()" and the set-method call is "setStartTime(value)".

By improper use of name capitalization, you upset this mechanism.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, now I learned but the problem still the same.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does your xhtml look like?

In JSF, unless you have precise matching between names, values will not display and JSF will not log any sort of error message.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XHTML:
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks valid, but your original backing bean class was named MedicosDAO. Your later examples use a class name of BeanMedicos, which confuses me. Most importantly, BeanMedicos is not shown with JSF @ManagedBean and @ViewScope annotations, And if you did not actually annotate BeanMedicos, JSF will not be able to work with it.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BeanMedicos is java class that contains the getter and setter. MedicosDAO is @ManagedBean.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not comprehend.

The only get/set methods that JSF can use are those that are attached to Managed Beans or to beans which have get/set methods that allow them to be accessed from a Managed Bean. If BeanMedicos is not a Managed Bean, then it does not matter whether it has getter/setter methods or not. It will be inaccessible from the h:outputText tags - and all other JSF tags as well.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I understand you but I am getting an error after change of managedBean.
Managed Bean:

Error msg:
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once again, you appear to have changed something and then reported an error without having shown the change that caused the error.

The error message says that you coded value="#{medicos.getnome}" on your xhtml. Your sample xhtml, however shows value="#{medicos.nome}"

The correct encoding is value="#{medicos.nome}". JSF will automatically resolve that to invoke getNome() on the medicos bean.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unknow "nome" property, this is that appear when I do that you say value="#{medicos.nome}".
Grid1.jpg
The Managed Bean.
The Managed Bean.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How you can see my managed bean show to choose "getnome" I don't know why.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your IDE does not understand JSF Expression Language. This is why you should not use an IDE as a replacement for understanding.

As to why I know that you coded "medicos.getnome", it's because the error message in the stack trace explicitly told me so.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry but this is not true. I have other class that this problem don't occur, for example in an tag <dataTable we have value and var parameters the var is used in <h:outputText to load bean elements, in <h:panelGrid we don't have value and var parameter outputText tag has value parameter then this is the question why is getnome displayed and not name. My example is showed in picture below.  You can compare with the picture above.
Pic-1.jpg
Image of my panelGrid.
Image of my panelGrid.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry last image is dataTable.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your IDE is not the authority on what JSF will and will not permit.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know, tell me why outputText show "getNome" and not "nome"?
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would have to ask the people who wrote NetBeans or whatever IDE you are using. JSF has no control over it.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I solved the problem changing my managed bean now I have another problem, I must to close this contact and open another or continue in this?
Thanks.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cezar Apulchro wrote:Hi, I solved the problem changing my managed bean now I have another problem, I must to close this contact and open another or continue in this?
Thanks.



It's generally better to give each question its own topic. We don't charge extra :) and it makes it easier for everyone to follow along.
 
Cezar Apulchro
Ranch Hand
Posts: 675
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, the solution to solve this problem is to do right. Tim told me about nomenclature getXxxx and setYyyy.
Thanks and best regards.
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic