Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay HashMap data in JSF page
    primarykey
    data
    text
    <p>I am struggling in displaying the content of hashmap in primefaces widgets like inputtext, selectonemenu etc etc. </p> <p>I have defined hasmaps</p> <pre><code> private Map&lt;String, String&gt; subIdMap = new HashMap&lt;String, String&gt;(); private Map&lt;String, Map&lt;String, String&gt;&gt; dataMap = new HashMap&lt;String, Map&lt;String, String&gt;&gt;(); </code></pre> <blockquote> <p>// their getter and setters.</p> </blockquote> <p><em>SubIdMap contains the keys and values</em> </p> <p><strong>for id 001</strong></p> <pre><code>private Map&lt;String, String&gt; subIdMap = new HashMap&lt;String, String&gt;(); subIdMap.put("id", "001"); subIdMap.put("name", "Alexender"); subIdMap.put("age", "24"); subIdMap.put("sex", "Male"); subIdMap.put("country", "Greece"); </code></pre> <p><strong>for id = 002</strong></p> <pre><code>private Map&lt;String, String&gt; subIdMap = new HashMap&lt;String, String&gt;(); subIdMap.put("id", "002"); subIdMap.put("name", "John"); subIdMap.put("age", "25"); subIdMap.put("sex", "Male"); subIdMap.put("country", "US"); </code></pre> <p>dataMap is a map which has ID's as keys and subIdMap as their values</p> <pre><code> private Map&lt;String, Map&lt;String, String&gt;&gt; dataMap = new HashMap&lt;String, Map&lt;String, String&gt;&gt;(); dataMap.put("001", subIdMap); or dataMap.put("002", subIdMap); </code></pre> <p>I have a page where if a user clicks on id 001, it will get the data for id =001 or for id =002 from bean and display in the xhtml page and . i am not able to show data from Map in the fields in xhtml page</p> <p><strong>snippet</strong></p> <pre><code> @ManagedBean(name = "sampleBean") @ViewScoped public class SampleBean implements Serializable{ private Map&lt;String, String&gt; subIdMap = new HashMap&lt;String, String&gt;(); private Map&lt;String, Map&lt;String, String&gt;&gt; dataMap = new HashMap&lt;String, Map&lt;String, String&gt;&gt;(); public SampleBean() { subIdMap.put("id", "001"); subIdMap.put("name", "Alexender"); subIdMap.put("age", "24"); subIdMap.put("sex", "Male"); subIdMap.put("country", "Greece"); dataMap.put("001",subIdMap); } /** * @return the subIdMap */ public Map&lt;String, String&gt; getSubIdMap() { return subIdMap; } /** * @param subIdMap the subIdMap to set */ public void setSubIdMap(Map&lt;String, String&gt; subIdMap) { this.subIdMap = subIdMap; } /** * @return the dataMap */ public Map&lt;String, Map&lt;String, String&gt;&gt; getDataMap() { return dataMap; } /** * @param dataMap the dataMap to set */ public void setDataMap(Map&lt;String, Map&lt;String, String&gt;&gt; dataMap) { this.dataMap = dataMap; } } </code></pre> <p><strong>xhtml page</strong></p> <pre><code>&lt;p:inputText id="textId" value="............." /&gt; &lt;p:selectOneMenu id="selectId" value="................" /&gt; </code></pre> <p>I need some directions here. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload