Hello,
I searched in google for the whole night, I couldn't found a working example for refreshing a datatable.
I have a CRUD table, I want to refresh the datatable when I add, edit and delete record from the table.
Is there any working example that I can follow?
I tried to implement something like this:
Thanks
Sam
How to refresh datatable without ajax?
-
- Posts: 69
- Joined: 22 Jan 2011, 11:04
I actually trying to press a Refresh button outside the table and within a form,
eg.
but it doesn't fire the roleController.refresh method.
Here is the refresh method in RoleController class:
Thanks
Sam
eg.
Code: Select all
<h:panelGrid columns="1" cellpadding="2">
<p:commandButton value="Refresh Table" action="#{roleController.refresh}" type="button" />
</h:panelGrid>
Here is the refresh method in RoleController class:
Code: Select all
public void refresh() {
roleList = loadAll();
logger.info("refresh rolelist: "+roleList.size());
}
Sam
Primefaces 2.2.1, JBOSS 6.0.0.Final, JDK1.6
You might be able to get some ideas from this showcase example: http://www.primefaces.org/showcase/ui/pprDataTable.jsf. It does however use ajax.
-
- Posts: 69
- Joined: 22 Jan 2011, 11:04
Hello,
Now it fires the refreshTable() method in the roleController, but the datatable in the view does not get refresh.
How to use Ajax refresh the view? I have tried to implement it in the Ajax way. Please see my xhtml file below:
Thanks
Sam
Now it fires the refreshTable() method in the roleController, but the datatable in the view does not get refresh.
How to use Ajax refresh the view? I have tried to implement it in the Ajax way. Please see my xhtml file below:
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:form id="f1">
<p:ajaxStatus style="width:16px;height:16px;">
<f:facet name="start">
<h:graphicImage value="" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
<h:panelGrid columns="2" cellpadding="2">
<p:commandButton value="Add New Role" onclick="addDlg.show();" type="button"/>
<p:commandButton value="Refresh Table" action="#{roleController.refreshTable}"
update=":f1:tableWrapper" />
</h:panelGrid>
<p:dialog header="Add New Role" modal="true" widgetVar="addDlg">
<ui:include src="add_new_role.xhtml"></ui:include>
</p:dialog>
<p:outputPanel id="tableWrapper">
<p:dataTable value="#{roleController.roles}" var="_role" paginator="true"
paginatorTemplate="{RowsPerPageDropDown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {CurrentPageReport}" rows="8"
emptyMessage="No Records to Display"
>
<p:column sortBy="#{_role.roleId}" filterBy="#{_role.roleId}">
<f:facet name="header">
<h:outputText value="Role ID" />
</f:facet>
<h:outputText value="#{_role.roleId}" />
</p:column>
<p:column sortBy="#{_role.roleName}" filterBy="#{_role.roleName}">
<f:facet name="header">
<h:outputText value="Role Name" />
</f:facet>
<h:outputText value="#{_role.roleName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Action" />
</f:facet>
<p:menuButton value="Actions">
<p:menuitem value="Add" url="http://www.primefaces.org" target="_blank" />
<p:menuitem value="Edit" url="http://www.cnn.com" target="_blank" />
<p:menuitem value="Delete" url="#" target="_blank" />
</p:menuButton>
</p:column>
</p:dataTable>
</p:outputPanel>
</h:form>
</html>
Thanks
Sam
Primefaces 2.2.1, JBOSS 6.0.0.Final, JDK1.6
-
- Information
-
Who is online
Users browsing this forum: No registered users and 44 guests