简体   繁体   中英

JSF Repeat nog showing value in checkbox

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM