primefaces: DataTable: filterBy is not called after AJAX update
Description DataTable is not calling the filterBy properties after ajax Update. The code was working in PF10 Community.
Environment:
- PF Version: 11.0.1
- PF Theme: Poseidon 4.1.0
- JSF 2.3 GlassFish 5.1
- Firefox and Chrome
Expected behavior function stated in p:dataTable filterBy is called by respecting the value from variable “showDeleted”. When the page is called the value for “showDeleted” is false. If the user set the value from Checkbox to true, the datatable should update and call the filterby Property again showDeleted is now true and the data should switch the fillter. In PF10 it works perfectly. In PF11 the function “objectController.getDefaultFilterMeta” is not called.
Example XHTML
<h:form id="frmInternalContact">
<p:remoteCommand name="refresh" update="dtaInternalContact" complete="PF('widInternalContact').filter()" />
<p:selectBooleanCheckbox id="sbcShowDeleted" value="#{iNCOController.showDeleted}" onchange="refresh()">
<p:ajax process="@this" />
</p:selectBooleanCheckbox>
<p:dataTable
id="dtaInternalContact"
value="#{iNCOController.items}"
var="row"
widgetVar="widInternalContact"
selectionMode="multiple"
liveScroll="false"
scrollable="true"
scrollHeight="630"
selection="#{iNCOController.selectedItems}"
filteredValue="#{iNCOController.filteredItems}"
filterBy="#{iNCOController.showDeleted ? objectController.getDefaultFilterMeta('defaultDeleted') :
objectController.getDefaultFilterMeta('dtaInternalContact')}"
sortBy="#{objectController.getDefaultSortMeta('dtaInternalContact')}"
sortMode="multiple"
allowUnsorting="true"
paginator="true"
paginatorPosition="bottom"
paginatorAlwaysVisible="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}"
currentPageReportTemplate="{totalRecords} record(s)"
rows="100"
rowsPerPageTemplate="100,200,300,400,500"
rowKey="#{row.internalContactPk}"
resizableColumns="true"
liveResize="true"
draggableColumns="true"
reflow="true"
showGridlines="true"
rowStyleClass="#{row.deleted ? 'row_deleted' : !row.activeFlag ? 'row_inactive' : null}"
styleClass="ui-datatable-striped ui-datatable-sm">
<p:columns value="#{iNCOController.mainTableColumns}"
var="column"
headerText="#{column.header}"
field="#{column.property}"
styleClass="#{column.adjust}"
style="width:#{column.width}"
visible="#{column.visible}"
filterable="#{column.filterable}"
filterMatchMode="#{column.type eq 'boolean' ? 'equals' : 'contains'}"
sortable="#{column.sortable}">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('widInternalContact').filter()" rendered="#{column.type eq 'boolean'}">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="True" itemValue="true" />
<f:selectItem itemLabel="False" itemValue="false" />
</p:selectOneMenu>
<p:selectOneMenu onchange="PF('widInternalContact').filter()" rendered="#{column.type eq 'state'}">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="Contact" itemValue="false" />
<f:selectItem itemLabel="List" itemValue="true" />
</p:selectOneMenu>
</f:facet>
<h:outputText rendered="#{column.type eq 'string'}" value="#{row[column.property]}" />
<h:outputText rendered="#{column.type eq 'datetime'}" value="#{row[column.property]}">
<f:convertDateTime locale="#{parameterSessionController.localeCode}" type="localDateTime" dateStyle="medium"
timeStyle="short"/>
</h:outputText>
<p:outputLabel rendered="#{column.type eq 'boolean' and row[column.property]}">
<i class="pi pi-check-circle" />
</p:outputLabel>
<p:outputLabel rendered="#{column.type eq 'state' and row[column.property] eq true}">
<i class="pi pi-list" />
</p:outputLabel>
<p:outputLabel rendered="#{column.type eq 'state' and row[column.property] eq false}">
<i class="pi pi-user" />
</p:outputLabel>
</p:columns>
</p:dataTable>
</h:form>
Example Bean
@Named
@SessionScoped
public class ObjectController implements Serializable {
private static final long serialVersionUID = 1L;
private Map<String,List<SortMeta>> sortMap = new HashMap<String,List<SortMeta>>();
private Map<String,List<FilterMeta>> filterMap = new HashMap<String,List<FilterMeta>>();
/* CONTROLLER CREATION DEFINITIONS */
public ObjectController () {
createDefaultSortMeta();
createDefaultFilterMeta();
}
public List<SortMeta> getDefaultSortMeta(String table) {
return sortMap.get(table);
}
public List<FilterMeta> getDefaultFilterMeta(String table) {
return filterMap.get(table);
}
private void createDefaultSortMeta() {
sm = new ArrayList<SortMeta>();
sm.add(SortMeta.builder().field("distributionList").order(SortOrder.ASCENDING).priority(1).build());
sortMap.put("dtaInternalContact", sm);
}
private void createDefaultFilterMeta() {
List<FilterMeta> fm = new ArrayList<FilterMeta>();
fm.add(FilterMeta.builder().field("deleted").filterValue(true).matchMode(MatchMode.EQUALS).build());
filterMap.put("defaultDeletedwoActive", fm);
fm = new ArrayList<FilterMeta>();
fm.add(FilterMeta.builder().field("activeFlag").filterValue(true).matchMode(MatchMode.EQUALS).build());
fm.add(FilterMeta.builder().field("deleted").filterValue(false).matchMode(MatchMode.EQUALS).build());
filterMap.put("dtaInternalContact", fm);
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (12 by maintainers)
@danteCarvalho please dont use this issue to talk about your issue, its quite different. Better see: https://github.com/primefaces/primefaces/issues/8159