I want to display a primefaces calendar element with an associated LocalDate in the Bean.
I used How to use java.time.ZonedDateTime / LocalDateTime in p:calendar as an example. The example as is works fine, BUT I don't need the time part and more importantly I don't want the time part of the calendar to be displayed.
The problem is that when I change the pattern and remove the time part:
<p:calendar id="localDate"
pattern="dd-MMM-yyyy"
value="#{bean.periodFrom}">
<f:converter converterId="localDateConverter" />
<p:ajax update="display" />
</p:calendar>
the converter is no longer called/ used at all. Which surprises me a bit.
Removing the pattern does not work neither.
Is there an alternative way to use the example without the time part? And why is the converter no longer called when I "simplify" the pattern?
JSF 2.2/ Java8/ Primefaces 6
The ajax update is not being triggered, because you didn't specify any event on which the update should be triggered.
If you do not specify any event, the default event type "change" will be used.
In your case, you should insert multiple event listeners:
<p:ajax update="display" />
<p:ajax event="dateSelect" update="display" />
So your code will result in:
<p:calendar id="localDate"
pattern="dd-MMM-yyyy"
value="#{bean.periodFrom}">
<f:converter converterId="localDateConverter" />
<p:ajax update="display" />
<p:ajax event="dateSelect" update="display" />
</p:calendar>
(By the way: It is not possible to combine multiple events in the same p:ajax component as you can read here https://stackoverflow.com/a/38319944/1643015)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With