• 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

JSF Datatable

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works after restarting NetBeans
 
Saloon Keeper
Posts: 27762
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 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 h:outputtext.
When i set var="test" i can use this in the output like
<h:outputText value="#{test.name}"/>
and it works.

Or is this not the way how datatable works?
 
Tim Holloway
Saloon Keeper
Posts: 27762
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

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 h:outputtext.
When i set var="test" i can use this in the output like
<h:outputText 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27762
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic