question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calendar: An error appears in the JS console when an invalid date is entered into a p:calendar textbox

See original GitHub issue

Describe the defect

An error appears in the JS console when an invalid date is entered into a p:calendar textbox.

This is a regression in PrimeFaces 8.0 – it does not happen with PrimeFaces 7.0.

Reproducer

  • Build the attached project and deploy the war to tomcat/webapps

Environment:

  • PF Version: 8.0
  • JSF + version: Mojarra 2.2.20
  • Affected browsers: ALL

To Reproduce

Expected behavior There will be no JS errors in the console.

Defect behavior

If the defect still exists, then the following error will appear in the JS console:

VM210:1 Uncaught SyntaxError: Unexpected token '?'
    at b (jquery.js.jsf?ln=primefaces&v=8.0:2)
    at Ie (jquery.js.jsf?ln=primefaces&v=8.0:2)
    at k.fn.init.replaceWith (jquery.js.jsf?ln=primefaces&v=8.0:2)
    at Object.updateElement (core.js.jsf?ln=primefaces&v=8.0:18)
    at Object.doUpdate (core.js.jsf?ln=primefaces&v=8.0:18)
    at Object.handle (core.js.jsf?ln=primefaces&v=8.0:18)
    at Object.<anonymous> (core.js.jsf?ln=primefaces&v=8.0:18)
    at c (jquery.js.jsf?ln=primefaces&v=8.0:2)
    at Object.fireWith [as resolveWith] (jquery.js.jsf?ln=primefaces&v=8.0:2)
    at l (jquery.js.jsf?ln=primefaces&v=8.0:2)

Example XHTML

<html xmlns="http://www.w3c.org/1999/xhtml"
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:h="http://xmlns.jcp.org/jsf/html"
	  xmlns:p="http://primefaces.org/ui">
<h:head/>
<h:body>
	<h:form id="f1">
		<h:panelGroup id="dateOfBirthField" layout="block">
			<p:calendar id="dateOfBirth" label="Date of Birth"
						required="true"
						pattern="MM/dd/yyyy" showOn="button"
						value="#{calendarBacking.dateOfBirth}">
				<f:convertDateTime pattern="MM/dd/yyyy"/>
				<p:ajax update="dateOfBirthField"/>
				<p:ajax event="dateSelect" update="dateOfBirthField"/>
			</p:calendar>
		</h:panelGroup>
		<hr/>
		<p:commandButton action="#{calendarBacking.submit}" update="f1"
						 value="Submit"/>
	</h:form>
</h:body>
</html>

Example Bean


import javax.faces.bean.ManagedBean;
import java.util.Date;

@ManagedBean
public class CalendarBacking {

	private Date dateOfBirth;

	public Date getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public void submit() {
		System.out.printf("Submitted");
	}
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ngriffin7acommented, Jul 10, 2020

@melloware Thanks so much for confirming that it’s fixed in Elite 8.0.2 and 9.0. Is there a tentative release schedule for 9.0?

0reactions
mellowarecommented, Jul 10, 2020

Well i don’t work for PrimeTek but base on the last 3 releases they are about once a year. 8.0 was released in March so I would guess 9.0 sometime early 2021 if their pattern holds…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Detecting an "invalid date" Date instance in JavaScript
Passing any value that the Date constructor can convert to a valid Date object is treated as a valid date, e.g. isValidDate(0) and...
Read more >
<input type="date"> - HTML: HyperText Markup Language
elements of type="date" create input fields that let the user enter a date, either with a textbox that validates the input or a...
Read more >
Date Field Popup issues | Adobe Acrobat
For a form with a Date field, when the Calendar popup is displayed ... popup errors telling you the data the field let...
Read more >
Common Problems with Google Calendar - Zapier
This may happen if the start and end time/date are invalid. Events created with an invalid start or end date will be created...
Read more >
Guides - Moment.js
The guides area is designed to help developers learn to better interact with the date and ... but rather increments or decrements the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found