Skip to content

Commit

Permalink
Fix primefaces#12234: 14.0.3 DatePicker initialize defaults on decode
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jul 3, 2024
1 parent 7518f1b commit bc96817
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@

public class DatePickerRenderer extends BaseCalendarRenderer {

@Override
public void decode(FacesContext context, UIComponent component) {
DatePicker datePicker = (DatePicker) component;

if (!shouldDecode(datePicker)) {
return;
}

initializeDefaults(context, datePicker);
super.decode(context, component);
}

@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
DatePicker datePicker = (DatePicker) component;
Expand All @@ -60,6 +72,18 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
return;
}

initializeDefaults(context, datePicker);

super.encodeEnd(context, component);
}

/**
* Initializes the default settings for the DatePicker component based on its pattern and value type.
*
* @param context the FacesContext instance
* @param datePicker the DatePicker component to initialize
*/
protected void initializeDefaults(FacesContext context, DatePicker datePicker) {
String pattern = datePicker.getPattern() == null ? datePicker.calculatePattern() : datePicker.getPattern();

if (datePicker.isShowTimeWithoutDefault() == null) {
Expand Down Expand Up @@ -88,8 +112,6 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
if (datePicker.isShowMillisecondsWithoutDefault() == null) {
datePicker.setShowMilliseconds(pattern.contains("S"));
}

super.encodeEnd(context, component);
}

protected void encodeDateMetadata(FacesContext context, DatePicker datePicker) throws IOException {
Expand Down

0 comments on commit bc96817

Please sign in to comment.