开发者

ui:repeat var attribute not working as expected

Due to the problem with @ViewScoped, I have to use ui:repeat instead of开发者_StackOverflow社区 c:foreach in my facelet. However I encounter this problem and I wonder if anyone can suggest a work-around.

<ui:repeat value="#{someBean.idCodes}"
           var="led">
           <h:outputText id="mailbox-#{led}" 
               value="#{someBean.getSomeValue(led)}" />
</ui:repeat>

The first problem is that the #{led} reference is the id attribute does NOT get evaluated. All the generated id attributes are simply the value "mailbox-". I need to find specific element instances with document.getElementById() so I need generated id attributes.

The other problem which I can't see a workaround for is that if I wrap the ui:repeat element inside an h:panelGrid element, I end up with a table with one cell in it, rather than one cell for each member of the idCodes collection.

When using c:foreach neither of these problems exist, but use of that tag causes other problems. Any suggestions?


Notice in the javadocs that the type of the id attribute is String, not ValueExpression. That's why your ${led} is not evaluated. You could try to wrap each one in a div or span and set the id of that element to your ${led} based expression.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜