question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Column: FilterValue Mutator Not Called

See original GitHub issue

Describe 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

  1. Clean/Build the attached reproducer
  2. Filter the DataTable Columns (Observe the console for which mutators are called during filtering)
  3. Click the CommandButton (Observe the console for which mutators are called during processing)
  4. Observe the Filter Values display on the screen
  5. Change the PrimeFaces version to 8.0.0 within the POM to see the previous behavior.

Attached PrimeFaces-Test Reproducer

column-filtervalue.zip

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:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Jul 13, 2022

i would never have found this without your reproducer so thanks!

1reaction
hink084commented, Jul 13, 2022

Wow, that’s a great find! Thanks for submitting a fix!!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found