• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confuse - a DataTable Attribute

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused about the "value" attribute of the h:dataTable. Take a look at the example below:



The "var" attribute of the <h:dataTable ..> is used to denote a Java Bean that has a number of attributes. For example: "#{mailBean.from}", "#{mailBean.to}", etc.

What does the "value" attribute in the <h:dataTable ..> do? Why do we need a mailForm? And the mailForm has a "mails" attribute?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- "value" represents the collection object representing the dataTable rows.
- "var" attribute represents the selected row in the datatable
 
Daniel Gee
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also interested in this topic. Therefore,

the "mailsForm" represents a collection of rows. and the "mailBean" represents each row in that collection.

Then, what is "mails" in "#{mailsForm.mails}"?
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...java.util.Lists, arrays, java.sql.ResultSets, and javax.servlet.jsp.jstl.sql.Results...
from ...

'mails' can be either an object of type 'javax.faces.model.DataModel', the easiest of which would probably be 'javax.faces.model.ListDataModel', or 'mails' can be a 'java.util.List', and array, a ResultSet, or the funky Result object in jstl (<-- correct?)

I generally use DataModel because then you just call 'getRowData' to get the selected object and you're on your way.
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that was confusing. I started quoting another forum, but then just decided to explain it. That should have been...


'mails' can be either an object of type 'javax.faces.model.DataModel', the easiest of which would probably be 'javax.faces.model.ListDataModel', or 'mails' can be a 'java.util.List', and array, a ResultSet, or the funky Result object in jstl (<-- correct?)

I generally use DataModel because then you just call 'getRowData' to get the selected object and you're on your way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!