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: Choosing browser selections triggers defaultCommand

See original GitHub issue

IMPORTANT

  • !!! 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

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:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Apr 5, 2019

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.

(function () {
    $.extend($.ui.keyCode, {
        NUMPAD_ENTER: 108
    });
}); 
0reactions
OBreidenbachcommented, May 9, 2019

I can confirm that with the fix the the default command is not triggered anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PrimeFaces 7.0.3 Released
... Calendar: Choosing browser selections triggers defaultCommand · Slider: NullPointerException when using in dynamic TabView.
Read more >
How to Print Calendar or Event Using Browser's Print Function
Step 1: Press Ctrl + P (for Windows) or Command + P (for macOS) to open the print dialogue. Alternately, in most browsers,...
Read more >
primefaces - issue #5690 - Google Code
There was an error obtaining the issue: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null] ...
Read more >
primefaces - issue #7796 - Google Code
Export to GitHub. primefaces - issue #7796. Add tabindex to TabView and DataTable. Posted on Dec 22, 2014 by Happy Rhino. For tab...
Read more >
Using Input Components and Defining Forms - 11g Release 1 (11.1 ...
For example, the File Explorer application contains a form that allows users to ... You can use either selection or list-of-values (LOV) components...
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