In my JSF view scoped form, I am using the poll tag to print minutes elapsed since the form was started, like this:
<h:outputText id="txt_count" value="You started #{mybean.timeElapsed} minutes ago" />
This is what I have in my backing bean. pollNumber is just an int. It works fine and prints minutes elapsed.
public String getTimeElapsed()
{
long diffInMinutes = java.time.Duration.between(startTime, LocalDateTime.now())
.toMinutes();
return String.valueOf(diffInMinutes);
}
public void increment(){
pollNumber++;
}
The problem is that I am using a custom date converter for a date in format MM/yyyy (a java.time.YearMonth). Every 5 seconds (the poll interval) the yearmonth date converter gets called, whether or not the date field is completely filled out. So one minute I am happily filling out my date field, the next I am redirected to a yucky stack trace:
Sorry, an error occurred Exception: Text '05/____' could not be parsed at index 3 Full stack trace: java.time.format.DateTimeParseException: Text '05/____' could not be parsed at index 3 at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949) at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
The problem goes away if I remove the p:poll tag. This is not a critical error. It's just weird. Any input would be appreciated. Thanks!