Skip to content

DatePicker: Date range filter on a DataTable is not restored when returning to the page #14265

@kpilandjr

Description

@kpilandjr

Describe the bug

Error condition happens if you have a DataTable with a date column that uses a date range filter using the DataPicker component and the DataTable is setup using multiViewState. With he multiViewState, a selected date range should be restored when you navigate away and return to the page, but the date range is not restored.

Running in development mode the following error and stacktrace appears in the console.

core.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:25 DatePicker Error: Missing number at position 0
error @ core.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:25
parseValueFromString @ datepicker.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:37
(anonymous) @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:20
parseValue @ datepicker.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:13
(anonymous) @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:20
_setInitValues @ datepicker.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:9
(anonymous) @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:20
_create @ datepicker.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:8
(anonymous) @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:20
_createWidget @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:24
e.<computed>.<computed> @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:19
(anonymous) @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:23
each @ jquery.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:2
each @ jquery.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:2
e.fn.<computed> @ jquery-plugins.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:23
init @ datepicker.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:136
(anonymous) @ core.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:125
d @ core.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:125
createWidget @ core.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:28
cw @ core.js.jsf?ln=primefaces&v=15.0.6&e=15.0.6:27
(anonymous) @ tasks.jsf:235

Sample column definition:

<p:column id="colDueDate" headerText="#{appmsg['column.project.tasks.due.date']}" sortBy="#{row.dueDate}"
    filterBy="#{row.dueDate}" filterMatchMode="between">
    <f:facet name="filter">
        <p:datePicker selectionMode="range" onchange="PF('tableAssignedProjectTasks').filter();"
            converter="javax.faces.DateTime" timeZone="#{systemTimezone}" />
    </f:facet>

I also captured this from the server response which shows the value it wants to assign to the filter as "Oct 20, 2024 - Oct 25, 2024" so I suspect something is trying to interpret that as a single date instead of two dates specifying a range.

<span id="frmAssignedProjectTasks:tblAssignedProjectTasks:j_idt164" class="p-datepicker ui-calendar">
    <input id="frmAssignedProjectTasks:tblAssignedProjectTasks:j_idt164_input" 
        name="frmAssignedProjectTasks:tblAssignedProjectTasks:j_idt164_input" type="text" 
        value="Oct 20, 2024 - Oct 25, 2024" class="ui-inputfield ui-widget ui-state-default" 
        role="combobox" aria-autocomplete="none" aria-haspopup="dialog" aria-expanded="false" 
        aria-controls="frmAssignedProjectTasks:tblAssignedProjectTasks:j_idt164_panel" 
        data-p-con="javax.faces.DateTime" data-p-dttype="date" data-p-dspattern="MMM d, y"/>
</span>

Reproducer

No response

Expected behavior

No response

PrimeFaces edition

None

PrimeFaces version

15.0.6

Theme

No response

JSF implementation

Mojarra

JSF version

2.3.14

Java version

11.0.13

Browser(s)

Chrome

Metadata

Metadata

Assignees

Labels

🐞 defectBug...Something isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions