New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker - TypeError: dayIndex is undefined (on windows only) #4473

Closed
rmpestano opened this Issue Jan 26, 2019 · 14 comments

Comments

Projects
None yet
3 participants
@rmpestano
Copy link

rmpestano commented Jan 26, 2019

Hi guys, I'm getting an js error with datepicker but only on windows machines (Firefox/Chrome/Edge - all with clean browser caches). I've tested on two different windows 7 and 8 computers and 3 Linuxes (Ubuntu) desktops. I have no issues on ubuntu machines.

It is important if someone else with windows machines could also test the provided sample project.


1) Environment

  • PrimeFaces version: 7.0-SNAPSHOT (commit hash: 1b86074)
  • Application server + version:Jetty 9
  • Affected browsers: Chrome 70/71, Edge and Firefox (62.3) and Edge (42.171)

2) Expected behavior

Datepicker should open.

3) Actual behavior

DatePicker doesn't open and page has javascript errors (it affects other componets and page get unusable)

4) Steps to reproduce

1 - Install primefaces 7.0-SNAPSHOT locally
2 - Download sample project (it is primefaces-test project with datepicker sample page) below:

primefaces-test.zip

3 - start application with mvn jetty:run
4 - access http://localhost:8080/primefaces-test/datepicker.xhtml

A quickier test is to access this page from a windows machine (or chrome/firefox for android which also fails but we cannot see the js errors).

5) Sample XHTML

see datepicker.xhtml on provided sample project

6) Sample bean

See DatePickerMB.java

7) Evidencies

Screenshots:

dayindex1

51780644-477e9600-20f7-11e9-8f3e-2e15d0b1cb8e

Firefox console log

firefox-log.txt

DatePicker.js being used (extrated from page source)

datepicker-widget.zip

@rmpestano

This comment has been minimized.

Copy link
Author

rmpestano commented Jan 26, 2019

Guys,

I`ve created a windows 10 VM and could not reproduce the issue, its working on all browsers both primefaces-test and the link I've provided.

It may be some kind of cache or browser version, please don't close this issue yet, I'll investigate a bit further.

@melloware

This comment has been minimized.

Copy link
Contributor

melloware commented Jan 26, 2019

I was testing this heavily on windows 10 yesterday and everything was looking good. Definitely let us know if you can reproduce j can try out what you find.

@rmpestano

This comment has been minimized.

Copy link
Author

rmpestano commented Jan 26, 2019

Hi @melloware, I just don't know what's happening.

Things I've done:

  • Took same primefaces jar which is working on the windows 10 VM
  • reinstaled firefox
  • clear browser caches dozens of times
  • use private ff windows
  • tested on chrome and FF

Things I've noticed:

  • It works on primefaces showcase (Also ran the showcase locally and it worked!)
  • it fails on two different windows machines (at my company and at home)
  • It works on 3 linuxes machines and one Windows machine under a virtualbox VM
  • it fails on two mobile phones (I suppose the issue is the same cause the symptoms are the same, datepicker doesn't show up and page is unusable/broken)
@melloware

This comment has been minimized.

Copy link
Contributor

melloware commented Jan 26, 2019

This weekend I will retest all 4 browsers on Windows 10 and let you know if I see anything strange. Chrome Firefox IE11 and Edge.

@rmpestano

This comment has been minimized.

Copy link
Author

rmpestano commented Jan 26, 2019

Look the generated html of the same page (with only an inline datepicker) on showcase (working) and on primefaces-test project:

The scripts look very similar:

prime-test
showcase

Now the component html was not generated completely on primefaces-test project:

pf-test-input
showcase-input

@rmpestano

This comment has been minimized.

Copy link
Author

rmpestano commented Jan 26, 2019

Alright, found the problem, it is a locale issue.

If you look carefully on the images above you'll see primefaces-test application was using my machine locale (PT_BR):

<script type="text/javascript">var pf=window.PrimeFaces;if(pf){pf.settings.locale='pt_BR';};
pf.cw("DatePicker","widget_form_inline",{id:"form:inline",inline:true,locale:"pt_BR",dateFormat:"dd\/mm\/y",selectionMode:"single",showOnFocus:true});</script>

forcing the locale to en (as primefaces showcase does) on faces-config solves the issue.

Now I think you can solve the issue, right? following is a sample app with pt_BR locale configured as default to reproduce the issue:

primefaces-test.zip

@melloware

This comment has been minimized.

Copy link
Contributor

melloware commented Jan 26, 2019

Yep that will help let me do some debugging

@mertsincan mertsincan self-assigned this Jan 28, 2019

@mertsincan mertsincan added this to the 7.0 milestone Jan 28, 2019

@mertsincan

This comment has been minimized.

Copy link
Member

mertsincan commented Jan 28, 2019

Hi @rmpestano,

Could you please test it again?

@rmpestano

This comment has been minimized.

Copy link
Author

rmpestano commented Jan 28, 2019

Hi @mertsincan,

I'm still getting the same error: TypeError: dayIndex is undefined[Learn More] datepicker.js.xhtml:214:17

screenshot from 2019-01-28 11-49-50

My local primefaces copy points to the following commit:

commit 6abcf67ff0fdc73027b9112e93fe692b1292a2ec (HEAD -> master, origin/master, origin/HEAD)
Author: mertsincan <sincan.mert@gmail.com>
Date:   Mon Jan 28 09:39:43 2019 +0300

    Fixed #4473

Does the sample application works for you?

@melloware

This comment has been minimized.

Copy link
Contributor

melloware commented Jan 28, 2019

@mertsincan the sample is still broken for me. I think what the component needs is to detect if the PrimeFaces.locale is not defined in the JS that it falls back to "en_US" and logs a warning to the console.

    configureLocale: function() {
        var localeSettings = PrimeFaces.locales[this.cfg.locale];

        if(localeSettings) {
            var locale = {};
            for(var setting in localeSettings) {
                locale[setting] = localeSettings[setting];
            }
            
            this.cfg.locale = locale;
        }
    },
@mertsincan

This comment has been minimized.

Copy link
Member

mertsincan commented Jan 28, 2019

@rmpestano and @melloware Please try again ;) Fix; 8417e00

melloware added a commit to melloware/primefaces that referenced this issue Jan 28, 2019

@melloware

This comment has been minimized.

Copy link
Contributor

melloware commented Jan 28, 2019

Looks good to me but better have @rmpestano chime in too. Since my default locale is en_US.

@rmpestano

This comment has been minimized.

Copy link
Author

rmpestano commented Jan 28, 2019

Yea it is working great now! thank you guys!

@mertsincan

This comment has been minimized.

Copy link
Member

mertsincan commented Jan 29, 2019

Glad to hear, thanks a lot for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment