Custom selectItems

2019-08-11 00:07发布

i want to customize selectItems to display an image conditionally beside each checkbox so first i tried to display the image for all checkboxes but it gets displayed only once, here's what i tried:

<h:selectManyCheckbox value="#{myBean.checkboxesArry}" layout="pageDirection">

              <f:selectItems value="#{myBean.mapOfCheckBoxes}" var="entry">                            
                <label>           
                <ice:graphicImage url="/resources/images/myImage.bmp"/>            
                <b>#{entry.value}</b>           
                </label>
              </f:selectItems>

            </h:selectManyCheckbox>

please advise how to accomplish that ?

1条回答
混吃等死
2楼-- · 2019-08-11 00:50

You cannot nest UI compnents in <f:selectItems> that way. I however see that you're using ICEfaces, you should then be able to use <ice:selectManyCheckbox layout="spread"> in combination with <ice:checkbox> instead.

<ice:selectManyCheckbox id="foo" value="#{myBean.checkboxesArry}" layout="spread">
    <f:selectItems value="#{myBean.mapOfCheckBoxes}" />
</ice:selectManyCheckbox>

<c:forEach items="#{myBean.mapOfCheckBoxes}" var="entry" varStatus="loop">
    <ice:checkbox for="foo" index="#{loop.index}" />
    <ice:graphicImage url="/resources/images/myImage.bmp" />
    <b>#{entry.value}</b>
</c:forEach>

(untested as I don't use ICEfaces, but the above construct works for Tomahawk, from which ICEfaces has basically copied the implementation; you can also use <ui:repeat> but it only supports Map since JSF 2.1)

See also:

查看更多
登录 后发表回答