JSF和JSTL不会像您期望的那样同步运行。JSTL在视图的构建期间(要填充JSF组件树)运行,而JSF在视图的组件树的呈现期间(要生成HTML输出)运行。您可以将其可视化如下:JSTL首先从上到下运行,然后将结果交给JSF,后者又从上到下运行。
在您的特定情况下,该对象
instance永远不会出现在JSTL中。
代替
c:forEach,应该使用
ui:repeat,而不是
c:if使用JSF组件的
rendered属性。我想重写代码,但是的用法
hideTypes很乱。而是将其转换
List<String>为模型中的,使用纯JSF会更加容易。这是一个假设
hideTypes为的启动示例
List<String>:
<h:panelGroup rendered="#{not empty hideTypes}"> <ui:repeat value="#{document.instanceList}" var="instance"> <a:outputPanel rendered="#{!hideTypes.contains(instance.documentInstanceType.mimeType)}"> <up:mimeTypeIcon type="#{instance.documentInstanceType.mimeType}" icon="#{instance.documentInstanceType.iconPath}" key="#{instance.instanceKey}" referenced="false"/> </a:outputPanel> </ui:repeat><h:panelGroup>


