Page 1 of 2

Bug Calendar processUpdates / updateModel

Posted: 14 Jan 2019, 13:08
by LarsD
Dear all.

I've got the following structure in my app:
- h:form
-- composite:component
--- p:calendar

The calendar is set up like this:

Code: Select all

	<p:calendar
		id=..."
		value="#{cc.attrs.valueFrom}" 
		pattern="dd.MM.yyyy"
		locale="de"
		navigator="true"
		converter="#{cc.attrs.converter}"
		styleClass="..."
		disabled="..."
		required="...">
		<p:ajax ... 
IMPORTANT: the value is a String object and the converter is a LocalDate -> String converter!

When entering a date with navigator or directly the conversion in the calender class is called and the conversion to String is correctly done by the converter. Ajax is also called, everything looks ok.

Now the problem:
When submitting the form and executing a search the calendar first takes the value correct and tries to submit the form. During rerendering the calender wants to rerender the input value, but it does not use the given pattern or converter, it uses the standard function of UIInput class.

The following methods were called:
- ...
- Calender(UIInput).processUpdates
- Calender(UIInput).updateModel
- ...
- ELSupport.coerceToType
- ...
- ELSupport.coerceToString
- LocalDate.ToString


Because LocalDate.toString gives a yyyy-MM-dd value, the value of the calender is in the wrong format.

In my app, the user can save the input values of a search, and the saved format is wrong then. Should be dd.MM.yyyy but is yyyy-MM-dd.

I think it is a bug, the Calender class should override the methods of UIInput to use the converter to get the correct String format of the input. PF version is 6.1.

kind regards

Lars

Re: Bug Calendar processUpdates / updateModel

Posted: 14 Jan 2019, 16:48
by kukeltje
Tried PF 6.2(.x) or 6.3-SNAPSHOT?

Re: Bug Calendar processUpdates / updateModel

Posted: 15 Jan 2019, 08:48
by LarsD
The API says it would make no difference because the methods are the same..
https://www.primefaces.org/docs/api/6.2 ... endar.html

Lars

Re: Bug Calendar processUpdates / updateModel

Posted: 15 Jan 2019, 12:04
by kukeltje
An API is not an implementation... ;-)

Re: Bug Calendar processUpdates / updateModel

Posted: 15 Jan 2019, 14:26
by Melloware
Yes please always test with the latest code. There are a lot of time something has long since been fixed.

Re: Bug Calendar processUpdates / updateModel

Posted: 16 Jan 2019, 15:52
by LarsD
PF 6.2 has the same problem.

According to the current implementation...

org.primefaces.component.calendar.Calendar
<- org.primefaces.component.calendar.CalendarBase
<<- org.primefaces.component.api.UICalendar
<<<- javax.faces.component.html.HtmlInputText
<<<<- javax.faces.component.UIInput

The class UIInput implements the mentioned methods which end up in the LocalDate.toString method as described.

The missing code should be implemented in some of the Calendar classes to use the converter instead of ELSupport.coerceToType as a fallback.


kind regards

Re: Bug Calendar processUpdates / updateModel

Posted: 16 Jan 2019, 16:04
by Melloware
OK do me a favor and create a small reproducible example using the PF Test project: https://github.com/primefaces/primefaces-test

Then submit the issue to the GitHub issues page.

Re: Bug Calendar processUpdates / updateModel

Posted: 17 Jan 2019, 17:18
by kukeltje
Please try 7.0RC1 since things have been 'fixed' in the calendar between 6.2 and now

Re: Bug Calendar processUpdates / updateModel

Posted: 29 Jan 2019, 07:58
by LarsD
I cannot change the PF version so easily. Looks like this is a gerneral issue which is not going to be fixed soon. :cry:

Re: Bug Calendar processUpdates / updateModel

Posted: 29 Jan 2019, 14:29
by Melloware
LarsD please report an issue on Github issues. if you don't report an issue on the GitHub page with a reproducible example then how can developers debug and fix your issue?