我正在尝试从现有的 Primefaces 组件构建一个自定义组件,我需要一些帮助。我有一个 selectOneMenu,我希望它根据在菜单中选择的选项来呈现或不呈现(并禁用或启用)其他组件。这里的困难是我不能使用托管 Bean 来做到这一点(我有几个原因),我需要一个纯 xhtml 代码。
我尝试了一些<c:choose>
东西<ui:parameter>
来创建布尔值,但由于某种原因,我看不到它不起作用。你们可以看看我的代码,看看你有什么想法吗?这可能是一些我无法理解的简单事情或我还不知道的事情。
<h:body>
<h:form id="abc">
<ui:repeat var="pd" value="#{produtoMB.produtos}">
<h:panelGroup id="linha">
<c:choose>
<c:when test="#{pd.marca == X1}">
<c:set var="render" value="#{true}" />
</c:when>
<c:otherwise>
<c:set var="render" value="#{false}" />
</c:otherwise>
</c:choose>
<p:selectOneMenu value="#{pd.marca}">
<f:selectItem itemLabel="Select One" itemValue="" noSelectionOption="true"/>
<f:selectItem itemLabel="Xbox One" itemValue="X1" />
<f:selectItem itemLabel="PlayStation 4" itemValue="PS4" />
<f:selectItem itemLabel="Wii U" itemValue="WU" />
<p:ajax update="linha" />
</p:selectOneMenu>
<p:inputText value="#{pd.aparelho}" disabled="#{render}"/>
<h:outputText value="Microsoft" rendered="#{render}"/>
<p:commandButton value="X" />
</h:panelGroup>
<br />
</ui:repeat>
<br />
<p:commandButton actionListener="#{produtoMB.botaoMais}" value="+" update="abc"/>
<p:commandButton actionListener="#{produtoMB.botaoMenos}" value="-" update="abc"/>
</h:form>