0

I'm passing a hashmap which consists out of an object + a boolean into my view and I want to display the value of the boolean of each object and currently have the following code:

<ui:repeat var="item" value="#{userTypeController.permissionItems}">
                    <h:outputText value="#{item}" />
                    <h:selectBooleanCheckbox value="#{userTypeController.checkMap[item]}"/>
    </ui:repeat>

And the Hashmap method:

    public Map<Permission, Boolean> getCheckMap() {
    checkMap = null;
    for (Permission p : getPermissionItems()) {
        if (getPermissionItemsUserType().contains(p))
            checkMap.put(p, Boolean.TRUE);
        else
            checkMap.put(p, Boolean.FALSE);
        System.out.println(checkMap.get(p).toString());
    }
    return checkMap;
}

This should work and during the system.out.println I see a true output...

However, the checkboxes itself are never checked... Any idea on what I'm doing wrong here?

SnIpY
  • 662
  • 2
  • 10
  • 27

1 Answers1

0

The symptoms which you describe matches Mojarra bug 1807 which was by coincidence fixed in 2.1.1 and was officially fixed in 2.1.4. So, upgrading Mojarra to at least 2.1.1 should do.

Note that you've a major bug in your code. You are nowhere instantiating the checkmap, it would throw a NullPointerException, although this seems to be oversimplifying of the code for the question. Also, doing this inside a getter is a bad idea. It should be done during the (post)construct or an event listener method. A getter can be called more than once during render response. See also Why JSF calls getters multiple times.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Upgraded to 2.1.4, still have the same issue... Anything else I could try? – SnIpY Nov 21 '11 at 19:20
  • Well, don't do the logic in the getter, but in the (post)constructor or whatever method which is called only once long before render response phase. Otherwise, a valid SSCCE would be helpful as yours contains bugs. – BalusC Nov 21 '11 at 19:22