Skip to content
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

SelectCheckboxMenu selected items not consistent with checkboxes in Firefox Quantum #2959

Closed
xxiFear opened this issue Nov 16, 2017 · 15 comments

Comments

@xxiFear
Copy link

xxiFear commented Nov 16, 2017

1) Environment

  • PrimeFaces version: 6.1
  • Does it work on the newest released PrimeFaces version? Version?
    ->Does not work on Primefaces Showcase
  • Does it work on the newest sources in GitHub? (Build by source -> https://github.com/primefaces/primefaces/wiki/Building-From-Source)
  • Application server + version: Tomcat 8.5.23
  • Affected browsers: Firefox Quantum

2) Expected behavior

Loading a page with a selectCheckboxMenu shows all items and - if selected items are prefilled - the checked checkbox.

3) Actual behavior

Prefilled selected items do get added as label to a "multi" checkboxMenu but regardless of the checkboxMenu mode (single, multi...) the checkboxes in the dropdown menu are not consistent. Instead, they show the last state before reloading the page. (Seems like they get chached somehow)

4) Steps to reproduce

  1. Open CheckboxMenu ShowCase
  2. Open Dropdown on Multiple checkboxMenu and select any item
  3. Reload page and check selected items. The selected item is still selected but not consistent with the selectedItems list, which is emtpy

showcase_checkboxmenu

5) Sample XHTML


6) Sample bean


@melloware
Copy link
Member

Is this only in Firefox or does it happen in Chrome/IE/Edge?

@xxiFear
Copy link
Author

xxiFear commented Nov 16, 2017

Only in Firefox Quantum (57.x)
Just tried with Chrome, IE and Edge and it works there.

@jxmai
Copy link
Contributor

jxmai commented Nov 16, 2017

Firefox cache the input by default for some reason so you probably need to set Cache-Control: no-store to avoid this problem.

If you press Ctrl + Shift + R in Firefox quantum, the checkbox value won't persist.

@melloware
Copy link
Member

I use OmniFaces cachcontrol filter...

http://omnifaces.org/

	<!-- No Cache Filter -->
	<filter>
		<filter-name>NoCacheFilter</filter-name>
		<filter-class>org.omnifaces.filter.CacheControlFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>NoCacheFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

@jxmai
Copy link
Contributor

jxmai commented Nov 16, 2017

Good resources 👍 . I was always using a custom servlet response to write the flag back. Looks like omnifaces can do the job without any code overhead.

@tandraschko
Copy link
Member

I just use this in my templates:

<h:head> <f:facet name="first"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="pragma" content="no-cache"/> <meta http-equiv="cache-control" content="no-cache"/> <meta http-equiv="expires" content="0"/>

@melloware
Copy link
Member

I actually use a bunch of Omnifaces filters that are awesome...

	<!-- UTF-8 Encoding filter over the default ISO-8859-1. -->
	<filter>
		<filter-name>CharacterEncodingFilter</filter-name>
		<filter-class>org.omnifaces.filter.CharacterEncodingFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>CharacterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<!-- Apply GZIP compression on responses whenever applicable -->
	<filter>
		<filter-name>GzipResponseFilter</filter-name>
		<filter-class>org.omnifaces.filter.GzipResponseFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>GzipResponseFilter</filter-name>
		<servlet-name>Faces Servlet</servlet-name>
	</filter-mapping>

	<!-- No Cache Filter -->
	<filter>
		<filter-name>NoCacheFilter</filter-name>
		<filter-class>org.omnifaces.filter.CacheControlFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>NoCacheFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<!-- adds an exception handler to unwrap exceptions in EL and regular page requests -->
	<filter>
		<filter-name>FacesExceptionFilter</filter-name>
		<filter-class>org.omnifaces.filter.FacesExceptionFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>FacesExceptionFilter</filter-name>
		<servlet-name>Faces Servlet</servlet-name>
	</filter-mapping>

@tandraschko
Copy link
Member

Just my thoughts:

  • no-cache in the header performs a little bit better as there is no fitler required each request
  • gzip is already available in all servers, no need to include extra code here

@jxmai
Copy link
Contributor

jxmai commented Nov 16, 2017

So, this issue is on showcase for not setting the flag properly I guess.

On the other hand, Firefox's caching system is a bit aggressive compared to other major browsers IMHO as they have been tried to do a lot of things to boost the performance in the latest release.

@melloware
Copy link
Member

Yep @xxiFear you can close this issue I have opened an issue on the Showcase to set the caching.

@xxiFear
Copy link
Author

xxiFear commented Nov 17, 2017

@melloware, @jxmai, @tandraschko Thank you very much for the help.

@xxiFear xxiFear closed this as completed Nov 17, 2017
@xxiFear
Copy link
Author

xxiFear commented Nov 17, 2017

I just tried your suggestion @tandraschko and it somehow still does not work in Firefox. Apart from that, it says "wrong attribute value" on all three meta tags.

@tandraschko
Copy link
Member

Yep, i see. Seems like these tags are not 100% safe to use and a fitler is the only 100% working approach.

@xxiFear
Copy link
Author

xxiFear commented Nov 17, 2017

@melloware You should change your showcase issue then.

@melloware
Copy link
Member

Agreed. I will kill my PR and submit a different one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants