【发布时间】:2026-02-13 05:35:01
【问题描述】:
我有一个 Facelet 标记文件,需要根据是否指定属性来呈现不同的组件。我试过如下,
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:panelGrid columns="1">
<p:outputLabel value="test1" rendered="#{empty myParam}" />
<p:outputLabel value="test2" rendered="#{not empty myParam}" />
</h:panelGrid>
</ui:composition>
如下使用,
<mt:myTag myParam="#{myManagedBean.someProperty}" />
但是,它没有用。它采用#{myManagedBean.someProperty} 的评估值。如果它是空的,那么它仍然显示test1。如何检查myParam 属性是否实际被设置?
【问题讨论】:
标签: jsf-2 attributes facelets tagfile conditional-rendering