I'm updating my web application to PF5.1 (was in PF4.0)
A simple update on the <p:dataTable>
component now destroy totally my datatable FILTER.
update=":#{p:component('tbl_queue')}"
I had to change my column filter because of the new PF5.1 version, so I modified my filters with :
<f:facet name="filter" >
<p:selectOneMenu ... >
<f:selectItem ... />
<f:selectItems ... />
</p:selectOneMenu>
</f:facet>
And the old filters version was :
<p:column id="..."
filterBy=...
filterOptions="..."
filterMatchMode="exact"
>
...
</p:column>
EDIT : My request is simple, it's to do a remove on a filtered datatable by selection (and to keep the filter alive). It was possible on PF4.0, it seems not of PF5.
Like that :
Step 1 : Filter the datatable
Step 2 : Remove one line by clicking 'Envoyer' = Remove (J91GT N9 03:17:00)
It's working fine on PF4, but I can't find a solution to do the same in PF5. EDIT 2:
<p:dataTable id="tbl_queue" var="c"
value="#{queueModificationController.cartQueue}"
widgetVar="queueTable"
filteredValue="#{queueModificationController.filteredCartQueue}"
rowKey = "#{c.id}"
>
<p:column
id="Bumper_column"
filterBy="#{c.name_bumper}"
headerText="Bumper"
filterMatchMode="exact"
>
<f:facet name="filter" >
<p:selectOneMenu onchange="PF('queueTable').filter()" id="selectFilterBumper" >
<f:selectItem itemLabel="Aucun" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{queueModificationController.nameBumperOptionsString}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{c.name_bumper}" />
</p:column>
<p:column>
//...
</p:column>
//...
//...
<p:column id="validation_column"
headerText="Validation">
<p:commandButton
action="#{productionQueue.updateAfterSending()}"
value="Validation"
update=":#{p:component('tbl_queue')}"
<f:setPropertyActionListener value="#{c}"
target="#{productionQueue.selectedCart}" />
</p:commandButton>
</p:column>
</p:dataTable>
--
@ManagedBean(name = "productionQueue")
@SessionScoped
private ArrayList<CartInQueueConsult> cartQueue; //filled by Database in bean initialisation
private ArrayList<CartInQueueConsult> filteredCartQueue = new ArrayList<CartInQueueConsult>(cartQueue);
public void updateAfterSending()
{
... (remove in database)
filteredCartQueue.remove(selectedCart);
cartQueue.remove(selectedCart);
}
EDIT : MCVE Example of the error :
Errors : - 1: The filter is not working (strange thing because all of my filters are working properly on no-MVCE example - 2: When you remove a Line with the button "Remove" the Filters are broken (my initial problem)
import java.io.Serializable;
import java.util.ArrayList;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;
@ManagedBean(name = "testController")
@ViewScoped
public class TestController implements Serializable
{
private ArrayList<String> cartQueue;
private String selectedCart;
private ArrayList<String> filteredCartQueue;
private SelectItem nameBumperOptionsString[] = {new SelectItem(1,"1"),new SelectItem(2,"2"),new SelectItem(3,"3"),new SelectItem(4,"4"),new SelectItem(5,"5")};
@PostConstruct
public void initialize()
{
cartQueue = new ArrayList<String>();
cartQueue.add("1");
cartQueue.add("2");
cartQueue.add("3");
cartQueue.add("4");
cartQueue.add("5");
cartQueue.add("6");
filteredCartQueue = cartQueue;
}
public void remove()
{
try
{
filteredCartQueue.remove(selectedCart);
cartQueue.remove(selectedCart);
}
catch (Exception ex)
{
System.out.println("EXCEPTION : "+ ex.getMessage());
}
}
public ArrayList<String> getFilteredCartQueue() {
return filteredCartQueue;
}
public void setFilteredCartQueue(ArrayList<String> filteredCartQueue) {
this.filteredCartQueue = filteredCartQueue;
}
public SelectItem[] getNameBumperOptionsString() {
return nameBumperOptionsString;
}
public void setNameBumperOptionsString(SelectItem nameBumperOptionsString[]) {
this.nameBumperOptionsString = nameBumperOptionsString;
}
public ArrayList<String> getCartQueue() {
return cartQueue;
}
public void setCartQueue(ArrayList<String> cartQueue) {
this.cartQueue = cartQueue;
}
public String getSelectedCart() {
return selectedCart;
}
public void setSelectedCart(String selectedCart) {
this.selectedCart = selectedCart;
}
}
_
<p:dataTable
id="test_queue" var="c"
value="#{testController.cartQueue}" widgetVar="testTable"
emptyMessage="Pas de file d'attente"
filteredValue="#{testController.filteredCartQueue}"
paginator="true"
currentPageReportTemplate="Nb Rows : {totalRecords}"
paginatorTemplate="{CurrentPageReport}"
>
<p:column id="number_column"
filterBy="#{c}"
headerText="Number"
filterMatchMode="exact"
>
<f:facet name="filter" >
<p:selectOneMenu onchange="PF('testTable').filter()" >
<f:selectItem itemLabel="Nothing" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{testController.nameBumperOptionsString}" />
</p:selectOneMenu>
</f:facet>
<center>
<h:outputText value="#{c}" />
</center>
</p:column>
<p:column headerText="Remove">
<center>
<p:commandButton
action="#{testController.remove()}"
value="Remove"
update="test_queue" >
<f:setPropertyActionListener value="#{c}" target="#{testController.selectedCart}" />
</p:commandButton>
</center>
</p:column>
</p:dataTable>
--
EDIT 3 : Lib :