Reputation: 27
I have to implement the search the functionality in primefaces dialog. After submitiing the search commandbutton the table beside the search needs to get updated. But everytime i am hitting the search button the popup gets closed. Please guide.Below is my code snippet for reference:
......
<p:commandButton id="search" value="Search" actionListener="#{createTicketBaseBean.searchUserFromList}" update="@form" onclick="dlg.show()"></p:commandButton>
</h:panelGrid>
</h:panelGroup>
<h:panelGroup style="float:right" >
<p:dataTable id="table" var="user" value="#{createTicketBaseBean.userList}" selection="#{createTicketBaseBean.selectedUser}" selectionMode="single" rowKey="#{user.email}" >
<p:column headerText="Name" >
<p:commandLink id="nameselect" value="#{user.name}" onclick="dlg.hide()"/>
</p:column>
<p:column headerText="Email">
<h:outputText value="#{user.email}" />
</p:column>
<p:column headerText="Department">
<h:outputText value="#{user.department}" />
</p:column>
</p:dataTable>
Upvotes: 0
Views: 1072
Reputation: 14277
Replace onclick
in your p:commandbutton
with oncomplete
. onclick
event is happening immediate when button is clicked. As this is AJAX button (in Primefaces this is default) there will be race conditioning between AJAX request and dialog opening. When using oncomplete
it will be called after AJAX request is completed.
Upvotes: 2