我有下面的面板,当页面加载时,它看起来像这样:
当您单击未显示的表格中的用户时,面板会更新,如下所示:
然后,当我单击“添加/删除组”按钮时,我希望选择列表出现,但我在firebug控制台中看到错误:
这里有什么问题?
<p:panel id="userDetails" header="User Details" styleClass="panels-right" visible="#{groupBacking.currentTable == 'Users'}">
<ui:fragment rendered="#{groupBacking.selectedUser != null}">
<p:commandButton value="Add/Remove Groups" styleClass="ui-priority-primary" actionListener="#{groupBacking.populateGroupPicklist}" oncomplete="PF('groupPicklistWidget').show()" />
<strong>User Id: </strong> <h:outputText value="#{groupBacking.selectedUser.ccsId}" /><br />
<strong>First Name: </strong> <h:outputText value="#{groupBacking.selectedUser.firstName}" /><br />
<strong>Last Name: </strong> <h:outputText value="#{groupBacking.selectedUser.lastName}" /><br />
<strong>Active: </strong> <h:outputText value="#{groupBacking.selectedUser.active}" /><br />
<strong>Groups: </strong>
<ui:repeat var="group" value="#{groupBacking.selectedUser.groups}">
<h:outputText value="#{group.name}" /><br />
</ui:repeat>
</ui:fragment>
<p:pickList widgetVar="groupPicklistWidget" id="groupPicklist" style="display: none;" value="#{groupBacking.picklistGroups}" var="group"
itemLabel="#{group.name}" itemValue="#{group.name}" showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains">
<f:facet name="available">Available</f:facet>
<f:facet name="assigned">Assigned</f:facet>
<p:ajax event="transfer" listener="#{groupBacking.onGroupTransfer}" update=":growl" />
</p:pickList>
<ui:fragment rendered="#{groupBacking.selectedUser == null}">
<h:outputText value="Click a user to see their details" />
</ui:fragment>
</p:panel>
答案 0 :(得分:0)
Primefaces 4 commandButton oncomplete给出错误PF(...)。show不是函数
我的demo.xhtml如下所示
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:form id="demoForm">
<p:commandButton id="hiddenSaveButton" value="AddRomove"
action="display" oncomplete="duplicateCheckDialog.show()"
style="float:right;"/>
<p:dialog id="dialog" header="Account Creation"
widgetVar="duplicateCheckDialog" resizable="true"
showEffect="bounce" hideEffect="fold" dynamic="true"
appendToBody="false" >
<div style="width: 100%" align="center">
<h:panelGrid id="display" columns="1" cellpadding="4">
<div style="float: left; width: 300px;">
<p:row>
<h:outputLabel value="Account No. already exists.
Please enter new Account No" style="font-weight: bold"/>
</p:row>
<p:row>
<p:commandButton id="backButton" title="Back" action="backPage"
value="Back" update=":demoForm:dialog" />
</p:row>
</div>
</h:panelGrid>
</div>
</p:dialog>
</h:form>
</html>
注意:在上面的示例中,我已将widget var id指定给该命令按钮标记。
你可以直接拨打oncomplete="duplicateCheckDialog.show()"
。 PF不是必需的
答案 1 :(得分:0)
我认为选项列表没有显示功能。如果要显示选项列表,可以在对话框中使用。在这种情况下,commandButton在oncomplete / onclick方法中调用groupDialogWidget
。示例代码如下:
<p:commandButton value="Add/Remove Groups" styleClass="ui-priority-primary" actionListener="#{testManagedBean.populateGroupPicklist}" onclick="groupDialogWidget.show();"/>
(...)
<p:dialog modal="true" showEffect="fade" hideEffect="fade" widgetVar="groupDialogWidget">
<p:pickList widgetVar="groupPicklistWidget" id="groupPicklist" value="#{testManagedBean.picklistGroups}" var="group"
itemLabel="#{group.name}" itemValue="#{group.name}" showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains">
<f:facet name="available">Available</f:facet>
<f:facet name="assigned">Assigned</f:facet>
</p:pickList>
</p:dialog>
如果您的目的是简单隐藏picketlist,您可以在bean中使用简单的boolean。当用户单击按钮时,此布尔值可以设置true / false。以下是picketlist的相关代码:
style= "#{testManagedBean.showPicketlist eq true ? 'display: block' : 'display: none'}"