Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As told in your <a href="https://stackoverflow.com/questions/3535923/returning-list-of-images-on-jsf-page">first question</a> about the subject, I have suggested to get hold of all images in a <code>Map&lt;String, List&lt;String&gt;&gt;</code> where the map key is the dropdown value and the map value is the collection of images.</p> <p>Since you can't seem to figure it out, here's a kickoff example how the JSF page should look like:</p> <pre><code>&lt;h:form&gt; &lt;h:selectOneMenu value="#{bean.groupName}"&gt; &lt;f:selectItem itemValue="Please select one" /&gt; &lt;f:selectItems value="#{bean.groupNames}" /&gt; &lt;f:ajax event="change" render="images" /&gt; &lt;/h:selectOneMenu&gt; &lt;h:panelGroup id="images"&gt; &lt;ui:repeat value="#{bean.images}" var="image"&gt; &lt;h:graphicImage value="#{image}" /&gt; &lt;/ui:repeat&gt; &lt;/h:panelGroup&gt; &lt;/h:form&gt; </code></pre> <p>And here's how the associated <code>Bean</code> should look like:</p> <pre><code>@ManagedBean @ViewScoped public class Bean { private Map&lt;String, List&lt;String&gt;&gt; allImages = new LinkedHashMap&lt;String, List&lt;String&gt;&gt;(); private List&lt;String&gt; groupNames; private String groupName; public Bean() { allImages.put("group1", Arrays.asList("group1a.jpg", "group1b.jpg", "group1c.jpg")); allImages.put("group2", Arrays.asList("group2a.jpg", "group2b.jpg", "group2c.jpg")); allImages.put("group3", Arrays.asList("group3a.jpg", "group3b.jpg", "group3c.jpg")); groupNames = new ArrayList&lt;String&gt;(allImages.keySet()); } public List&lt;String&gt; getImages() { return allImages.get(groupName); } public List&lt;String&gt; getGroupNames() { return groupNames; } public String getGroupName() { return groupName; } public void setGroupName(String groupName) { this.groupName = groupName; } } </code></pre>
 

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