DatePicker: month/year navigator isn't updated correctly when using LazyDateMetadataModel
See original GitHub issueDescribe the defect When using a DatePicker with month/year navigator, combined with a model (eg. for disabling days), the month/year selected values are reverted to the first elements in the lists. Eg. current year is 2021, the list is populated 10 years before and after the current year (2011-2031). The selected year will display as 2011, but internally, 2021 is still used, which is correct. Same things happens for the month selector. The days however are displayed correctly (correct month and year, including the state applied by the model). When using mindate and maxdate instead of the model, it is working correctly.
Environment:
- PF Version: 10.0
- JSF + version: Mojarra 2.3.9.SP09
- Affected browsers: ALL (I could reproduce this with Chrome, Firefox and Edge, all updated to latest version. Haven’t tested it with other browsers)
To Reproduce Steps to reproduce the behavior:
- Create a DatePicker with month and/or year navigator, using a LazyDateMetadataModel
- Open the datepicker popup by clicking on the input field.
- selected another month, either by selecting it from the navigator selection lists, or by using the navigation buttons to go to the next or previous month.
- The DatePicker popup will be updated, the dates will be correctly displayed, but the month/year navigator will be resetted to the first selectable element in the list.
Expected behavior The month/year navigator should not be resetted to the first selectable element in the list, but should contain the currently selected month/year.
Example XHTML
<p:datePicker model="#{bean.modelLazy}" monthNavigator="true" yearNavigator="true"/>
Example Bean
LazyDateMetadataModel modelLazy = new LazyDateMetadataModel() {
@Override
public void loadDateMetadata(LocalDate start, LocalDate end) {
add(start.plusDays(start.getMonthValue() + 2), DefaultDateMetadata.builder().disabled(true).build());
}
};
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
@Melloware I confirm the patch works! Thanks for the very fast fix for this problem!
@pmensalt I believe this MonkeyPatch will work if you want to try it right now…