aspose file tools*
The moose likes JSF and the fly likes JSF Datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF Datatable " Watch "JSF Datatable " New topic
Author

JSF Datatable

Robert Richter
Greenhorn

Joined: Dec 16, 2012
Posts: 11
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

Joined: Dec 16, 2012
Posts: 11
It works after restarting NetBeans
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

Your datatable value bean name was "Location", not "location", so if that was actually what you had coded, it would have been a problem.


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

Joined: Dec 16, 2012
Posts: 11
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

Joined: Jun 25, 2001
Posts: 16014
    
  20

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

Joined: Dec 16, 2012
Posts: 11
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

Joined: Jun 25, 2001
Posts: 16014
    
  20

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

Joined: Dec 16, 2012
Posts: 11
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF Datatable