我正在使用JSF创建一个小应用程序,面对异常,下面是表单的代码。
<h:form>
<h:selectManyCheckbox value="#{transferMB.selectedItems}">
<f:selectItem itemValue="1" itemLabel="Transfer Status" />
<p:ajax update=":transForm" />
</h:selectManyCheckbox>
</h:form>
异常“javax.faces.view.facelets.TagAttributeException:”
答案 0 :(得分:1)
您应该在渲染的属性中调用Boolean-like
值。
示例:
<p:panelGroup id="group" rendered="{#bean.isOneSelected}">
...
</p:panelGroup>
<p:panelGroup id="group" rendered="{#bean.isTwoSelected}">
...
</p:panelGroup>
从selectManyMenu获取值。请检查here。
渲染标签也是Boolean
类似条件,用于判断是否应显示标签。您不应该将参数传递给它。您应该从transferMB
答案 1 :(得分:1)
如上所述,您需要使用EL 2.2在EL-Expressions中传递参数。似乎你没有使用它。
所以我们需要另一种方法来解决这个问题:
<h:form id="transForm">
<p:panelGrid columns="1" rendered="#{transferMB.transFormEnabled}">
<h:outputText value="transForm"/>
</p:panelGrid>
</h:form>
<h:form id="spreadForm">
<p:panelGrid columns="1" rendered="#{transferMB.spreadFormEnabled}">
<h:outputText value="spreadForm"/>
</p:panelGrid>
</h:form>
并在相应的bean中:
public boolean isTransFormEnabled() {
if (selectedItems.contains("1")) {
return true;
} else {
return false;
}
}
public boolean isSpreadFormEnabled() {
if (selectedItems.contains("2")) {
return true;
} else {
return false;
}
}