Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6980639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:03:06+00:00 2026-05-27T18:03:06+00:00

I have a Map of key / values, which I initialize in @PostConstruct as

  • 0

I have a Map of key / values, which I initialize in @PostConstruct as follows:

Map<String, String> myMap;

@PostConstruct
public void init() {

  myMap=new LinkedHashMap<String, String>();
  myMap.put("myKey","myValue");

}

public Map<String, String> getMyMap() {
    return myMap;
}

public void setMyMap(Map<String, String> myMap) {
    this.myMap = myMap;
}

When I try to iterate over this Map with <ui:repeat> like shown bellow, and I set a break point on the getter for the Map, I notice that it is not getting called, and so nothing is printed:

<ice:panelGroup>
    <ui:repeat items="#{myBean.myMap}" var="entry" varStatus="loop">
        <input type="checkbox" name="myCheckBoxes" value="#{entry.value}" />
        <span class="#{fn:contains(entry.value,'g') ? 'bold-style' : ''}">#{entry.key}</span>
    </ui:repeat>
</ice:panelGroup>

But when replacing above code with <c:foreach>, everything works fine, and the list is printed as expected, any ideas why I am getting such behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:03:07+00:00Added an answer on May 27, 2026 at 6:03 pm

    UPDATE: JSF 2.3 (since 2017) supports this out of the box.

    Unfortunately, UIData and UIRepeat have no support for iterating over a map in JSF.

    If this bothers you (I guess it does), please vote for the following issue and if possible leave a comment that explains how you feel about this:

    http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-479

    In the mean time, you can iterate over a Map with some little helper code:

    /**
     * Converts a Map to a List filled with its entries. This is needed since 
     * very few if any JSF iteration components are able to iterate over a map.
     */
    public static <T, S> List<Map.Entry<T, S>> mapToList(Map<T, S> map) {
    
        if (map == null) {
            return null;
        }
    
        List<Map.Entry<T, S>> list = new ArrayList<Map.Entry<T, S>>();
        list.addAll(map.entrySet());
    
        return list;
    }
    

    Then define an EL function in a *-taglib.xml file like this:

    <namespace>http://example.com/util</namespace> 
    
    <function>
        <function-name>mapToList</function-name>
        <function-class>com.example.SomeClass</function-class>
        <function-signature>java.util.List mapToList(java.util.Map)</function-signature>
    </function>
    

    And finally use it on a Facelet like this:

    <html xmlns:util="http://example.com/util">
    
        <ui:repeat value="#{util:mapToList(someDate)}" var="entry" >
            Key = #{entry.key} Value = #{entry.value} <br/>
        </ui:repeat>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code private Map<KEY, Object> values = new HashMap<KEY, Object>(); public
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
In a controller, I have populated a map that has a string as key
I have an interface for a creaky property-map: interface IPropertyMap { bool Exists(string key);
Suppose that I have a multimap (which maps multiple values to a single key),
Let us say we have a key with values which are polymorphic in their
I made a servlet which creates a Map Object: Map<String, Integer> data = new
I have a map which I have declared as follows: map<int, bool> index; and
In Scala 2.8, I have an immutable map with multiple values for each key:
I have a map which contains integer values. i want to re-arange this map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.