开发者

JSF rich:dataList rendered per row?

Seems like this should be possible but ...?

Using richfaces and JSF I'm iterating over a List using rich:dataList ... all is fine except I'd like the ability to selectively 'render' each iteration, is that possible?

For example:

<rich:dataList value="#{list}" va开发者_如何学运维r="item">
   <h:outputText value="#{item.something}" />
</rich:dataList>

I'd like to be able to render the output selectively, for example if some property of 'item' is true or whatever.

I've tried wrapping the outputText in an outputPanel and similar but if the output panel is not rendered the '<li>' of the iteration is still rendered so you get a bullet point with nothing beside it rather than it just skipping the item entirely :(

Any way of solving this or am I SOL? I realize normally I'd want to get the List of items to display ready before hand but for many reasons I won't bother to repeat here it isn't possible.


Odd behaviour. I tried to reproduce it with Tomahawk's t:dataList and I am seeing exactly the same behaviour! Best what you can do is to replace it by a4j:repeat and render plain HTML <li> elements manually. Something like:

<ul class="rich-datalist">
    <a4j:repeat value="#{list}" var="item">
        <h:panelGroup rendered="#{item.somecondition}">
            <li class="rich-list-item">
                <h:outputText value="#{item.something}" />
            </li>
        </h:panelGroup>
    </a4j:repeat>
</ul>

(I've borrowed same classnames from rich:dataList as described here so that it keeps the skin)

I personally would however mark it as a bug or at least as undesireable behaviour and report it to the boys behind the component library in question. I've already done it for Tomahawk.


Simple. Add the rendered attribute to the h:outputText tag.

<rich:dataList value="#{list}" var="item">
    <h:outputText value="#{item.something}" rendered="#{item.isDisplayed}"/>
</rich:dataList>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜