Calendar: Choosing browser selections triggers defaultCommand
See original GitHub issueIMPORTANT
-
!!! If you open an issue, fill every item. Otherwise the issue might be closed as invalid. !!!
-
Please use the naming convention for the title: ${component}: ${title} Example: SelectOneMenu: Converter not called
-
Before you open an issue, test it with the current/newest version.
-
Try to find an explanation to your problem by yourself, by simply debugging. This will help us to solve your issue 10x faster
-
Clone this repository https://github.com/primefaces/primefaces-test.git in order to reproduce your problem, you’ll have better chance to receive an answer and a solution.
-
Otherwise the example must be as small and simple as possible! It must be runnable without any other dependencies (like Spring,…, or project/company internal classes)!
-
Feel free to provide a PR (Primefaces is an open-source project, any fixes or improvements are welcome.)
1) Environment
- PrimeFaces version: 7.0
- Does it work on the newest released PrimeFaces version? Version? No. Release 7.0
- Does it work on the newest sources in GitHub? (Build by source -> https://github.com/primefaces/primefaces/wiki/Building-From-Source) No
- Application server + version: wildfly 10.1
- Affected browsers: Chrome
Use case
Having a calendar and a defaultCommand in one form. Using chrome browser click in calendar field. Chrome offers a list with suggestions. Select one of the suggestions.
2) Expected behavior
Chrome fills the text field of the calendar with the value of the selected suggestion. That is the behavior with PrimeFaces 6.2.
3) Actual behavior
With PrimeFaces 7.0 the selection of a selection triggers the default command. That is also true for the datePicker, maybe also other components.
4) Steps to reproduce
Use chrome to fill the example. Second time clicking the calendar field, chrome offers a suggestion. Click on the selection to select it. On PrimeFaces 7.0 the alert method is executed. This does not happen with PrimeFaces 6.2.
5) Sample XHTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>PrimeFaces Test</title>
</h:head>
<h:body>
<h:form id="myForm">
<p:calendar id="calendar"
value="#{testViewCdi.date}"
navigator="true"
showButtonPanel="true"/>
<br/><!--
<p:datePicker id="datePicker"
value="#{testViewCdi.date}"/>
<br/>-->
<p:commandButton id="save"
value="Save"
onclick="alert('Save button clicked!!!');"
action="#{testViewCdi.save()}"
ajax="false"/>
<p:defaultCommand target="save"/>
</h:form>
</h:body>
</html>
6) Sample bean
package org.primefaces.test;
import java.util.Date;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
@Named
@RequestScoped
public class TestViewCdi {
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public void save() {
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
The code that used to make this work in 6.2 was removed because of this ticket: https://github.com/primefaces/primefaces/issues/3615 It seems like this is a country dependent solution?
To temporarily make this work again add this JavaScript somewhere on your page.
I can confirm that with the fix the the default command is not triggered anymore.