'Primefaces: Switching between dataTables with a radioButton breaks filter dropdown
I have a component that contains a dataTable in a separate .xhtml file. In that dataTable, one of the columns supports filtering with a dropdown (providing a list of values that can be filtered by):
myDocTable.xhtml
<composite:interface>
<composite:attribute name="id" type="java.lang.String" required="false" default="docTable"/>
...
</composite:interface>
<composite:implementation>
<p:dataTable var="document"
...
<p:column headerText="Creator" filterBy="#{document.erfuser}">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('#{cc.attrs.id}').filter()"
filter="true" filterText="Filter" filterMatchMode="contains">
<f:selectItem itemDescription="#{msgs.general_select_one}" noSelectionOption="true" />
<f:selectItems value="#{backbean.getFilterValues()}" var="person" itemLabel="#{person.getSID()}"
itemDescription="#{person.getSID()}" itemValue="#{person.id}" />
</p:selectOneMenu>
</f:facet>
...
</p:column>
...
/>
</composite:implementation>
I use this component in an other .xhtml file, where I use a radio button to switch between different modes of the above table, like this:
outer.xhtml
...
<f:facet name="legend">
<h1><h:outputText value="View:" /></h1>
<p:selectOneRadio id="doc_radioBtn" widgetVar="doc_radioBtn"
value="#{backbean.tableMode}" required="true">
<p:ajax update="panelDocTable" />
<f:selectItem itemLabel="Mode1" itemValue="tableMode1"/>
<f:selectItem itemLabel="Mode2" itemValue="tableMode2"/>
<f:selectItem itemLabel="Mode3/Anlagen" itemValue="tableMode3"/>
</p:selectOneRadio>
</f:facet>
<p:outputPanel id="panelDocTable">
<c:choose>
<c:when test="#{backbean.tableMode == 'tableMode1'}">
<mllf:myDocTable id="docTableForMode1" *some other parameters ...*/>
</c:when>
<c:when test="#{rechtsaktView.dokumenteTabelleModus == 'tableMode2'}">
<mllf:myDocTable id="docTableForMode2" *some other parameters ...*/>
</c:when>
...
...
This generally works as intended, expect for the f:selectItems , which causes problems. It works fine for the first table that is loaded (the table that is loaded due to the default value of backbean.tableMode) , meaning I get a dropdown with the values I would expect in the column header. However, when I then change the table mode using the radio button (thus loading a different table), I get the following error:
Method not found: class com.google.common.base.Absent.getSID()
Apparently backbean.getFilterValues() is not called properly for any table except the first. For the implementation of backbean.getFilterValues(), I tried both getting values from my DB as well as taking the data that the dataTable is displaying and mapping it to the dropdown values, but the problem occurs in both cases.
What could cause this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
