Describe the defect
As per the documentation on the Datepicker component, copying and modifying one of the configurations (specifically the text for currentText and clearText) for a specific locale available here https://github.com/primefaces/primefaces/wiki/Locales, does not change the text for the Today and Clear buttons.
Also, clearing the component value using the corresponding "Clear" button does not fire the dateSelect event, making it impossible to refresh other components like a datatable while using it as a filter.
Environment:
To Reproduce
Given the following markup for a datatable column:
<p:column style="text-align: left"
headerText="Date"
sortBy="#{someBean.date}"
filterBy="#{someBean.date}"
filterMatchMode="exact">
<f:facet name="filter">
<p:datePicker
pattern="dd/MM/yyyy"
showButtonBar="true"
locale="es"
monthNavigator="true"
yearNavigator="true"
readonlyInput="true"
showIcon="true"
selectionMode="range">
<p:ajax event="dateSelect" oncomplete="PF('dateTable').filter()"/>
</p:datePicker>
</f:facet>
<h:outputText value="#{someBean.date}">
<f:convertDateTime pattern="dd/MM/yyyy" timeZone="America/New_York" type="localDate"/>
</h:outputText>
</p:column>
And using the "es" locale configuration as follows and importing it in a js file:
PrimeFaces.locales['es'] = {
closeText: 'Cerrar',
prevText: 'Anterior',
nextText: 'Siguiente',
monthNames: ['Enero','Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun','Jul','Ago','Sep','Oct','Nov','Dic'],
dayNames: ['Domingo','Lunes','Martes','Mi茅rcoles','Jueves','Viernes','S谩bado'],
dayNamesShort: ['Dom','Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'],
dayNamesMin: ['D','L','M','X','J','V','S'],
weekHeader: 'Semana',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: '',
timeOnlyTitle: 'S贸lo hora',
timeText: 'Tiempo',
hourText: 'Hora',
minuteText: 'Minuto',
secondText: 'Segundo',
currentText: 'Fecha actual',
ampm: false,
month: 'Mes',
week: 'Semana',
day: 'D铆a',
allDayText : 'Todo el d铆a',
messages: { //optional for Client Side Validation
'javax.faces.component.UIInput.REQUIRED': '{0}: Error de validaci贸n: se necesita un valor.',
'javax.faces.converter.IntegerConverter.INTEGER': '{2}: \'{0}\' debe ser un n煤mero formado por uno o varios d铆gitos.',
'javax.faces.converter.IntegerConverter.INTEGER_detail': '{2}: \'{0}\' debe ser un n煤mero entre -2147483648 y 2147483647. Ejemplo: {1}',
'javax.faces.converter.DoubleConverter.DOUBLE': '{2}: \'{0}\' debe ser un n煤mero formado por uno o varios d铆gitos.',
'javax.faces.converter.DoubleConverter.DOUBLE_detail': '{2}: \'{0}\' debe ser un n煤mero entre 4.9E-324 y 1.7976931348623157E308 Ejemplo: {1}',
'javax.faces.converter.BigDecimalConverter.DECIMAL': '{2}: \'{0}\' debe ser un n煤mero decimal positivo o negativo.',
'javax.faces.converter.BigDecimalConverter.DECIMAL_detail': '{2}: \'{0}\' debe ser un n煤mero decimal positivo o negativo formado por cero o m谩s d铆gitos, que pueden incluir a continuaci贸n una coma decimal y una fracci贸n. Ejemplo: {1}',
'javax.faces.converter.BigIntegerConverter.BIGINTEGER': '{2}: \'{0}\' debe ser un n煤mero formado por uno o varios d铆gitos.',
'javax.faces.converter.BigIntegerConverter.BIGINTEGER_detail': '{2}: \'{0}\' debe ser un n煤mero formado por uno o varios d铆gitos. Ejemplo: {1}',
'javax.faces.converter.ByteConverter.BYTE': '{2}: \'{0}\' debe ser un n煤mero entre 0 y 255.',
'javax.faces.converter.ByteConverter.BYTE_detail': '{2}: \'{0}\' debe ser un n煤mero entre 0 y 255. Ejemplo: {1}',
'javax.faces.converter.CharacterConverter.CHARACTER': '{1}: \'{0}\' debe ser un car谩cter v谩lido.',
'javax.faces.converter.CharacterConverter.CHARACTER_detail': '{1}: \'{0}\' debe ser un car谩cter ASCII v谩lido.',
'javax.faces.converter.ShortConverter.SHORT': '{2}: \'{0}\' debe ser un n煤mero formado por uno o varios d铆gitos.',
'javax.faces.converter.ShortConverter.SHORT_detail': '{2}: \'{0}\' debe ser un n煤mero entre -32768 y 32767 Ejemplo: {1}',
'javax.faces.converter.BooleanConverter.BOOLEAN': '{1}: \'{0}\' debe ser \'true\' o \'false\'',
'javax.faces.converter.BooleanConverter.BOOLEAN_detail': '{1}: \'{0}\' debe ser \'true\' o \'false\'. Cualquier valor diferente a \'true\' se evaluar谩 como \'false\'.',
'javax.faces.validator.LongRangeValidator.MAXIMUM': '{1}: Error de validaci贸n: el valor es mayor que el m谩ximo permitido de \'{0}\'',
'javax.faces.validator.LongRangeValidator.MINIMUM': '{1}: Error de validaci贸n: el valor es inferior que el m铆nimo permitido de \'{0}\'',
'javax.faces.validator.LongRangeValidator.NOT_IN_RANGE': '{2}: Error de validaci贸n: el atributo especificado no est谩 entre los valores esperados {0} y {1}.',
'javax.faces.validator.LongRangeValidator.TYPE={0}': 'Error de validaci贸n: el valor no tiene el tipo correcto.',
'javax.faces.validator.DoubleRangeValidator.MAXIMUM': '{1}: Error de validaci贸n: el valor es mayor que el m谩ximo permitido de \'{0}\'',
'javax.faces.validator.DoubleRangeValidator.MINIMUM': '{1}: Error de validaci贸n: el valor es inferior que el m铆nimo permitido de \'{0}\'',
'javax.faces.validator.DoubleRangeValidator.NOT_IN_RANGE': '{2}: Error de validaci贸n: el atributo especificado no est谩 entre los valores esperados {0} y {1}',
'javax.faces.validator.DoubleRangeValidator.TYPE={0}': 'Error de validaci贸n: el valor no tiene el tipo correcto.',
'javax.faces.converter.FloatConverter.FLOAT': '{2}: \'{0}\' debe ser un n煤mero formado por uno o varios d铆gitos.',
'javax.faces.converter.FloatConverter.FLOAT_detail': '{2}: \'{0}\' debe ser un n煤mero entre 1.4E-45 y 3.4028235E38 Ejemplo: {1}',
'javax.faces.converter.DateTimeConverter.DATE': '{2}: \'{0}\' no se ha podido reconocer como fecha.',
'javax.faces.converter.DateTimeConverter.DATE_detail': '{2}: \'{0}\' no se ha podido reconocer como fecha. Ejemplo: {1}',
'javax.faces.converter.DateTimeConverter.TIME': '{2}: \'{0}\' no se ha podido reconocer como hora.',
'javax.faces.converter.DateTimeConverter.TIME_detail': '{2}: \'{0}\' no se ha podido reconocer como hora. Ejemplo: {1}',
'javax.faces.converter.DateTimeConverter.DATETIME': '{2}: \'{0}\' no se ha podido reconocer como fecha y hora.',
'javax.faces.converter.DateTimeConverter.DATETIME_detail': '{2}: \'{0}\' no se ha podido reconocer como fecha y hora. Ejemplo: {1}',
'javax.faces.converter.DateTimeConverter.PATTERN_TYPE': '{1}: debe especificarse el atributo \'pattern\' o \'type\' para convertir el valor \'{0}\'',
'javax.faces.converter.NumberConverter.CURRENCY': '{2}: \'{0}\' no se ha podido reconocer como un valor de divisa.',
'javax.faces.converter.NumberConverter.CURRENCY_detail': '{2}: \'{0}\' no se ha podido reconocer como un valor de divisa. Ejemplo: {1}',
'javax.faces.converter.NumberConverter.PERCENT': '{2}: \'{0}\' no se ha podido reconocer como porcentaje.',
'javax.faces.converter.NumberConverter.PERCENT_detail': '{2}: \'{0}\' no se ha podido reconocer como porcentaje. Ejemplo: {1}',
'javax.faces.converter.NumberConverter.NUMBER': '{2}: \'{0}\' no se ha podido reconocer como fecha.',
'javax.faces.converter.NumberConverter.NUMBER_detail': '{2}: \'{0}\' no es un n煤mero. Ejemplo: {1}',
'javax.faces.converter.NumberConverter.PATTERN': '{2}: \'{0}\' no es un patr贸n num茅rico.',
'javax.faces.converter.NumberConverter.PATTERN_detail': '{2}: \'{0}\' no es un patr贸n num茅rico. Ejemplo: {1}',
'javax.faces.validator.LengthValidator.MINIMUM': '{1}: Error de validaci贸n: el largo es inferior que el m铆nimo permitido de \'{0}\'',
'javax.faces.validator.LengthValidator.MAXIMUM': '{1}: Error de validaci贸n: el largo es mayor que el m谩ximo permitido de \'{0}\'',
'javax.faces.validator.RegexValidator.PATTERN_NOT_SET': 'Se debe establecer el patr贸n de Regex.',
'javax.faces.validator.RegexValidator.PATTERN_NOT_SET_detail': 'El patr贸n Regex debe establecerse en un valor no vac铆o.',
'javax.faces.validator.RegexValidator.NOT_MATCHED': 'El patr贸n Regex no coincide',
'javax.faces.validator.RegexValidator.NOT_MATCHED_detail': 'El patr贸n Regex de \'{0}\' no coincide',
'javax.faces.validator.RegexValidator.MATCH_EXCEPTION': 'Error en expresi贸n regular.',
'javax.faces.validator.RegexValidator.MATCH_EXCEPTION_detail': 'Error en expresi贸n regular, \'{0}\'',
//optional for bean validation integration in client side validation
'javax.faces.validator.BeanValidator.MESSAGE': '{0}',
'javax.validation.constraints.AssertFalse.message': 'debe ser falso',
'javax.validation.constraints.AssertTrue.message': 'debe ser verdadero',
'javax.validation.constraints.DecimalMax.message': 'debe ser menor que o igual a {0}',
'javax.validation.constraints.DecimalMin.message': 'debe ser mayor que o igual a {0}',
'javax.validation.constraints.Digits.message': 'valor num茅rico fuera de los l铆mites (se esperaba (<{0} digitos>.<{1} digitos>)',
'javax.validation.constraints.Future.message': 'debe ser una fecha futura',
'javax.validation.constraints.Max.message': 'debe ser menor que o igual a {0}',
'javax.validation.constraints.Min.message': 'debe ser mayor que o igual a {0}',
'javax.validation.constraints.NotNull.message': 'no debe ser nulo',
'javax.validation.constraints.Null.message': 'debe ser nulo',
'javax.validation.constraints.Past.message': 'debe ser una fecha pasada',
'javax.validation.constraints.Pattern.message': 'debe coincidir con "{0}"',
'javax.validation.constraints.Size.message': 'el tama帽o debe estar entre {0} y {1}'
}
};
Does not change the label for the "Today" and "Clear" labels. Also, it does not make an ajax call to apply the filter whenever the clear button is clicked in order to reset the filter for the datatable.
Expected behavior
The "Today" and "Clear" button labels should change in order to reflect what is configured in the configuration JS script. It also should fire the event for dateSelected whenever the clear button is clicked in order to apply the filter and refresh the datatable.
```
Thanks for reporting I will let you know what I find out.
OK first things first. I updated the WIKI: https://github.com/primefaces/primefaces/wiki/Locales
It was missing these values for DatePicker. Thanks for pointing that out!
today: 'Hoy',
clear: 'Claro',
Reproducer showing it fixed:
pf-6034.zip
If you need this fix right now just add this JS to your application:
PrimeFaces.widget.DatePicker.prototype.bindCloseListener = function() {
var $this = this;
if (this.hasBehavior('close')) {
this.cfg.onBeforeHide = function() {
$this.fireCloseEvent();
};
}
this.cfg.onClearButtonClick = function(event) {
$this.callBehavior('dateSelect');
};
}