Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF Datatable

 
Robert Richter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
i want to display some values in a datable. i have read some examples, but it didn´t work.
The Datatable displayed nothing, but the Systemout shows that the ResultSet isn´t empty.
i hope you can help me.
here are the classes that i use.

The First one creates the ArrayList and the second one is used in the first to generate the list.



And this is the code for the Datatable.
 
Robert Richter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works after restarting NetBeans
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your datatable value bean name was "Location", not "location", so if that was actually what you had coded, it would have been a problem.
 
Robert Richter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Your datatable value bean name was "Location", not "location", so if that was actually what you had coded, it would have been a problem.


I think the value that you choose in the parameter "var" is the reference that you have to call in the hutputtext.
When i set var="test" i can use this in the output like
<hutputText value="#{test.name}"/>
and it works.

Or is this not the way how datatable works?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert Richter wrote:
Tim Holloway wrote:Your datatable value bean name was "Location", not "location", so if that was actually what you had coded, it would have been a problem.


I think the value that you choose in the parameter "var" is the reference that you have to call in the hutputtext.
When i set var="test" i can use this in the output like
<hutputText value="#{test.name}"/>
and it works.

Or is this not the way how datatable works?


You are correct. Looking closer, it appears that you named your backing bean "Location" and your "var" you named "location". Which is confusing.

Especially since you should not give backing beans names that begin with an upper-case letter.
 
Robert Richter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okey Thank you :-)
But I have another question, maybe you can help me again.
I want to create a tableheader...i try it with a <f:facet> tag, but it didnt work. this is the example where I look it up (http://www.mkyong.com/jsf2/jsf-2-datatable-example/)


here is the html output that is generated
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using an h:outputText element instead of raw text in your facet body.

BTW, a "table header" can be defined by putting a header facet before the column definitions. If you put a header facet within a column definition, it will be a column header.
 
Robert Richter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:Try using an h:outputText element instead of raw text in your facet body.

BTW, a "table header" can be defined by putting a header facet before the column definitions. If you put a header facet within a column definition, it will be a column header.


Great :-) with an h:outputText it works...yes you´re right, i don´t want a tableheader but a column header.
Tank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic