{"action":"opened","issue":{"url":"https://api.github.com/repos/primefaces/primefaces/issues/517","labels_url":"https://api.github.com/repos/primefaces/primefaces/issues/517/labels{/name}","comments_url":"https://api.github.com/repos/primefaces/primefaces/issues/517/comments","events_url":"https://api.github.com/repos/primefaces/primefaces/issues/517/events","html_url":"https://github.com/primefaces/primefaces/issues/517","id":94721983,"number":517,"title":"Client-side filter() resets / ignores pagination","user":{"login":"lazlev","id":7804514,"avatar_url":"https://avatars.githubusercontent.com/u/7804514?v=3","gravatar_id":"","url":"https://api.github.com/users/lazlev","html_url":"https://github.com/lazlev","followers_url":"https://api.github.com/users/lazlev/followers","following_url":"https://api.github.com/users/lazlev/following{/other_user}","gists_url":"https://api.github.com/users/lazlev/gists{/gist_id}","starred_url":"https://api.github.com/users/lazlev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lazlev/subscriptions","organizations_url":"https://api.github.com/users/lazlev/orgs","repos_url":"https://api.github.com/users/lazlev/repos","events_url":"https://api.github.com/users/lazlev/events{/privacy}","received_events_url":"https://api.github.com/users/lazlev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-13T13:35:33Z","updated_at":"2015-07-13T13:35:33Z","closed_at":null,"body":"When using datatable filtering one has to use the client-side filter option like this PF('widgetVar').filter()\r\n\r\nMy goal is to stay on the current page the user has navigated to after performing actions like inserting or deleting entries via a command button. The problem is that the client-side filter() call resets or ignores the pagination value \"first\" which can be  used to set the page.\r\n\r\n#### xhtml ####\r\n    <!DOCTYPE html>\r\n    <html xmlns:p=\"http://primefaces.org/ui\"\r\n    \txmlns:c=\"http://java.sun.com/jsp/jstl/core\"\r\n    \txmlns:f=\"http://java.sun.com/jsf/core\"\r\n    \txmlns:fn=\"http://java.sun.com/jsp/jstl/functions\"\r\n    \txmlns:h=\"http://java.sun.com/jsf/html\"\r\n    \txmlns:ui=\"http://java.sun.com/jsf/facelets\">\r\n    <h:head>\r\n    \t<title>datatable filter</title>\r\n    </h:head>\r\n    <h:body>\r\n    \t<div id=\"main\">\r\n    \t\t<h:form id=\"contentRegion\">\r\n    \t\t\t<div class=\"reportsRegion\">\r\n    \t\t\t\t<div class=\"title\">Processes</div>\r\n    \t\t\t\t<div class=\"content\">\r\n    \t\t\t\t\t<p:dataTable id=\"dataTableProcesses\" widgetVar=\"processWidget\"\r\n    \t\t\t\t\t\tvalue=\"#{processView.processes}\" var=\"process\" paginator=\"true\"\r\n    \t\t\t\t\t\trows=\"10\" selection=\"#{processView.selectedProcess}\"\r\n    \t\t\t\t\t\tselectionMode=\"single\" rowKey=\"#{process.id}\"\r\n    \t\t\t\t\t\tfilteredValue=\"#{processView.filteredProcesses}\"\r\n    \t\t\t\t\t\tsortBy=\"#{process.id}\" sortOrder=\"ascending\" style=\"width:1080px;\">\r\n    \r\n    \t\t\t\t\t\t<p:column id=\"processId\" headerText=\"ID\" sortBy=\"#{process.id}\"\r\n    \t\t\t\t\t\t\tfilterBy=\"#{process.id}\" filterMatchMode=\"contains\">\r\n    \t\t\t\t\t\t\t<h:outputText value=\"#{process.id}\" />\r\n    \t\t\t\t\t\t</p:column>\r\n    \r\n    \t\t\t\t\t\t<p:column id=\"processActive\" headerText=\"Active\"\r\n    \t\t\t\t\t\t\tsortBy=\"#{process.active}\" filterBy=\"#{process.id}\">\r\n    \t\t\t\t\t\t\t<h:outputText value=\"#{process.active}\" />\r\n    \t\t\t\t\t\t</p:column>\r\n    \t\t\t\t\t</p:dataTable>\r\n    \t\t\t\t\t<p:commandButton id=\"deleteProcessButton\" value=\"Delete Process\"\r\n    \t\t\t\t\t\ticon=\"ui-icon-trash\" update=\":contentRegion:dataTableProcesses\"\r\n    \t\t\t\t\t\tactionListener=\"#{processView.deleteSelectedProcess}\"\r\n    \t\t\t\t\t\toncomplete=\"PF('processWidget').filter(); alert('pause')\" />\r\n    \t\t\t\t</div>\r\n    \t\t\t</div>\r\n    \t\t</h:form>\r\n    \t</div>\r\n    </h:body>\r\n    </html>\r\n\r\n#### Backing bean ####\r\n    package com.test.beans;\r\n    \r\n    import java.io.Serializable;\r\n    import java.util.ArrayList;\r\n    import java.util.List;\r\n    \r\n    import javax.annotation.PostConstruct;\r\n    import javax.faces.context.FacesContext;\r\n    import javax.faces.event.ActionEvent;\r\n    import javax.faces.view.ViewScoped;\r\n    import javax.inject.Named;\r\n    \r\n    import org.primefaces.component.datatable.DataTable;\r\n    import org.primefaces.context.RequestContext;\r\n    import org.slf4j.Logger;\r\n    import org.slf4j.LoggerFactory;\r\n    \r\n    import com.test.data.Process;\r\n    \r\n    @Named(value = \"processView\")\r\n    @ViewScoped\r\n    public class ProcessView implements Serializable\r\n    {\r\n    \tprivate static Logger log = LoggerFactory.getLogger(ProcessView.class);\r\n    \tprivate static final long serialVersionUID = 649545086989524867L;\r\n    \t\r\n    \tprivate List<Process> processes;\r\n    \tprivate List<Process> filteredProcesses;\r\n    \tprivate Process selectedProcess;\r\n    \r\n    \tprivate int paginatorRow;\r\n    \tprivate int activeFilter;\r\n    \t\r\n    \t@PostConstruct\r\n    \tpublic void init()\r\n    \t{\r\n    \t\tprocesses = new ArrayList<Process>();\r\n    \t\tfor (int i = 1; i < 60; i++)\r\n    \t\t{\r\n    \t\t\tprocesses.add(new Process(i, i%2));\r\n    \t\t}\r\n    \t\tfilteredProcesses = new ArrayList<Process>();\r\n    \t\t\r\n    \t\tsetActiveFilter(1);\r\n    \t}\r\n    \t\r\n    \tpublic void deleteSelectedProcess(ActionEvent event)\r\n    \t{\r\n            if (this.selectedProcess != null)\r\n            {\r\n            \tprocesses.remove(selectedProcess);\r\n            \tselectedProcess = null;\r\n            \tDataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent(\"contentRegion:dataTableProcesses\");\r\n        \t\tif (dataTable != null)\r\n        \t\t{\r\n        \t\t\tdataTable.setFirst(10); // Set page to 2\r\n        \t\t}\r\n            }\r\n    \t}\r\n    \r\n    \tpublic List<Process> getProcesses()\r\n    \t{\r\n    \t\treturn processes;\r\n    \t}\r\n    \r\n    \tpublic void setProcesses(List<Process> processes)\r\n    \t{\r\n    \t\tthis.processes = processes;\r\n    \t}\r\n    \r\n    \tpublic List<Process> getFilteredProcesses()\r\n    \t{\r\n    \t\treturn filteredProcesses;\r\n    \t}\r\n    \r\n    \tpublic void setFilteredProcesses(List<Process> filteredProcesses)\r\n    \t{\r\n    \t\tthis.filteredProcesses = filteredProcesses;\r\n    \t}\r\n    \r\n    \tpublic Process getSelectedProcess()\r\n    \t{\r\n    \t\treturn selectedProcess;\r\n    \t}\r\n    \r\n    \tpublic void setSelectedProcess(Process selectedProcess)\r\n    \t{\r\n    \t\tthis.selectedProcess = selectedProcess;\r\n    \t}\r\n    \r\n    \tpublic int getPaginatorRow()\r\n    \t{\r\n    \t\treturn paginatorRow;\r\n    \t}\r\n    \r\n    \tpublic void setPaginatorRow(int paginatorRow)\r\n    \t{\r\n    \t\tthis.paginatorRow = paginatorRow;\r\n    \t}\r\n    \r\n    \tpublic int getActiveFilter()\r\n    \t{\r\n    \t\treturn activeFilter;\r\n    \t}\r\n    \r\n    \tpublic void setActiveFilter(int activeFilter)\r\n    \t{\r\n    \t\tthis.activeFilter = activeFilter;\r\n    \t}\r\n    }\r\n\r\n#### POJO ####\r\n    package com.test.data;\r\n    \r\n    public class Process\r\n    {\r\n    \tprivate long id;\r\n    \tprivate int active;\r\n    \t\r\n    \tpublic Process(long id, int active)\r\n    \t{\r\n    \t\tthis.id = id;\r\n    \t\tthis.active = active;\r\n    \t}\r\n    \tpublic long getId()\r\n    \t{\r\n    \t\treturn id;\r\n    \t}\r\n    \tpublic void setId(long id)\r\n    \t{\r\n    \t\tthis.id = id;\r\n    \t}\r\n    \tpublic int getActive()\r\n    \t{\r\n    \t\treturn active;\r\n    \t}\r\n    \tpublic void setActive(int active)\r\n    \t{\r\n    \t\tthis.active = active;\r\n    \t}\r\n    }\r\n\r\nIn this example I have a commandButton to delete the currently selected entry. In the actionListener I additionally set pagination to page 2.\r\n\r\nTo reproduce the behavior set the filter of column id to '1', select a row and press the delete button. After calling the client-side filter in oncomplete, an alert window gets opened to pause the execution. Now the datatable has switched to page 2. After closing the alert window a refresh gets triggered and the view is reset to page 1.\r\n\r\nI'd expect the view to stay on page 2.\r\n\r\nAnother user reported this behavior on Stackoverflow, too:\r\nhttp://stackoverflow.com/questions/24532180/primefaces-paginator-always-jumping-to-page-1\r\n\r\nI'm using PF 5.2, MyFaces 2.2.7, WELD 2.2.9, Tomcat 7.0.47"}}