Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Convert hashmap values to arraylist to display in jsf page  RSS feed

 
Omar Ali
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need your help in assigning the selected hashmap values into a list and to display the values in a jsf page. The user will select certificates and will be stored in the below list:


The selectedCertificates will have the values ("AA","BB"). Now I will be passing the list into a hashmap in order to get the names and to display them on the jsf page.

My code is below:



I want to display in my jsf page :

Certificate A
Certificate B

Now my issue is that is how to display all the values of the CertificatesNames.get(key1) in the jsf page as I tried to do the below and it printed all the values when I used the #{mybean.beans} using the :


So how to do this?
 
Tim Holloway
Bartender
Posts: 18705
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I read that properly, you wish a tabular display on the webpage (View). The JSF collection-oriented controls (dropdown list and datatable) cannot use a Hash-based object as their model because a hash is not a collection from which you can sequentially retrieve values and always have the same relative order of the values even after insertions and deletions. Hashes are not Ordered Collections. You need a sequential (ordered) collection such as a List or array.

To display a 2-dimensional table where you have 2 columns such as "key" and "value" displayed, you must construct a custom class for the row data with the required properties (key and value), then assemble an ordered collection (List or array) of the row objects with their repective key/value pairs. You can use that directly as an h:dataTables "value" model or you can wrap the collection in a JSF DataModel class (for example, ListDataModel). The DataModel classes allow you access to context information if you want to initiate actions based on which row of the displayed table the user selected.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!