Column: FilterValue Mutator Not Called
See original GitHub issueDescribe the bug
The defined Column filterValue within a DataTable does not store the value within the backing bean when processed - the mutator method is not called. This behavior changed when migrating from PrimeFaces v8 to PrimeFaces v10. As of 7/12/2022 this issue is still present within the PrimeFaces 12.0-SNAPSHOT.
There is a workaround which is to manually define the filter utilizing the filter facet. You can also bind the DataTable and access the filterValues via the DataTable API but that method is not shown here.
<h:form id="frmTest">
<h2>1) Filter the Animal and Sound columns: {dog, woof}</h2>
<p:dataTable id="dt_test" value="#{testView.items}" var="item" widgetVar="wgt_test">
<!-- Broken FilterValue -->
<p:column filterBy="#{item.animal}"
filterValue="#{testView.animalFilter}"
headerText="Animal"
id="col_animal">
#{item.animal}
</p:column>
<!-- Workaround Filter -->
<p:column filterBy="#{item.sound}"
headerText="Sound"
id="col_sound">
<f:facet name="filter">
<p:inputText value="#{testView.soundFilter}" onkeyup="PF('wgt_test').filter();"/>
</f:facet>
#{item.sound}
</p:column>
</p:dataTable>
<br/><br/>
<h2>2) Click the Button</h2>
<p:commandButton id="btn_show"
partialSubmit="true"
process="@this, dt_test"
update="animalFilter, soundFilter"
value="Show Filter Values"/>
<br/><br/>
<h2>3) Observe Values</h2>
Animal Filter Value: <h:outputText id="animalFilter"
value="#{not empty testView.animalFilter ? testView.animalFilter : '- Empty -'}"/>
<br/>
Sound Filter Value: <h:outputText id="soundFilter"
value="#{not empty testView.soundFilter ? testView.soundFilter : '- Empty -'}"/>
<br/><br/>
<h4>Column filterValue mutator was called in PrimeFaces v8 but not in PrimeFaces v10+</h4>
</h:form>
Reproducer
- Clean/Build the attached reproducer
- Filter the DataTable Columns (Observe the console for which mutators are called during filtering)
- Click the CommandButton (Observe the console for which mutators are called during processing)
- Observe the Filter Values display on the screen
- Change the PrimeFaces version to 8.0.0 within the POM to see the previous behavior.
Attached PrimeFaces-Test Reproducer
Expected behavior
I’d expect the filterValue to be accessible/stored in the backing bean.
PrimeFaces edition
Community
PrimeFaces version
11.0.0
Theme
bootstrap
JSF implementation
Mojarra
JSF version
2.3
Browser(s)
All
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Mutator is called but it doesn't change the attribute in model
I created a ticket_price column as decimal(9,4) in DB. Then I created a simple mutator: public function setTicketPriceAttribute($value) { return 2; } ...
Read more >Laravel mutator isn't setting the new value - Stack Overflow
When I run the code, contents of the "test" column in db is not 1234, it's the data that comes from the $data...
Read more >Mutators & Accessors - Tabulator
For a mutator to work the column definition must have a field property specified, otherwise the muator will not know which field to...
Read more >5.5. Mutator Methods — AP CSAwesome - Runestone Academy
These are called mutator methods (or settters or set or modifier methods). They are void methods meaning that they do not return a...
Read more >Accessor and Mutator methods in Python - GeeksforGeeks
It can set the value of a variable instantly to a new value. This method is also called as update method. Moreover, we...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i would never have found this without your reproducer so thanks!
Wow, that’s a great find! Thanks for submitting a fix!!