This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Showing a List of Maps in a dataTable  RSS feed

 
Chagh asdf
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
How can we show a List of Maps in a DataTable in JSF? (Rows iterate on List and columns iterate on Maps index. like a table with dynamic header and values.)

<b>Verbose Question:</b>
I am new to JSF and developing a search application using it. I've got a search.jsp page which a user can type his query in it and also choose his results format from some checkboxes whithin this page.
I've got a Document class which has got different attributes of a document like its name, ceator, etc . result format contains some attributes of a Document which the user wants to see in the results page.
when the search is done via a search API i fill a List of a Map as the search result and pass it to my result.jsp page. a List 'cause number of founded documents can be more thn one and a Map 'cause user can choose different attributes of a Document to e shown and this map is of pairs of <attributeName, attributeValue> (e.g. <"creator", "Alex">)
Now I want to show this List of Maps in my Result.jsp page so that the header of my dataTable tekes its values from the Map index(first element of each pair) and each row represent a document.
(e.g. the results table:
creator docName path
------------------------------------------------
Alex test.txt c:/temp/test.txt
--------------------------------------------------
Ach new.doc c:/new.doc
)

Thanks in advance
--Chagh
 
Rafa de Castro
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that to be possible with only a datatable.

Have you tried with a datatable inside a datatable?
 
Chagh asdf
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thank you for the reply, yes i tried that but it didn't work. it didn't show any of the tables! anyway i passes all the header to my JSP page and used a boolean attribute in the bean for "rendered" of datatable columns. It is not a good way and i am waiting for other replies patiently!

Regards
--Chagh
 
Rafa de Castro
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm starting to think that JSF dataTable doesn't support unordered collections such as Map or Set. Try transforming the map into a list of lists.
 
Rafa de Castro
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems so. I've written some code and it's true what I stated before.

Transform the list of maps into a list of lists and then pass it to the datatable.

Then it will work.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!