selectManyCheckbox changes value after page refresh in firefox

UI Components for JSF
Post Reply
eframsergio
Posts: 46
Joined: 11 Jul 2019, 18:40

20 Sep 2022, 00:24

so I have a webpage with a list of products to the right and list of filtering grouped keywords to the left in a selectManyCheckbox component. the selectManyCheckbox selections are stored in a session-level variable.

when an item (filter keyword) is checked in the filter, I of course would filter the products list, but I also filter the selectManyCheckbox criteria keywords itself to narrow down the options (I simulate this in the test project) based on what has been already selected as criteria.

the problem I have is that some options that have never been checked, returned as checked after refreshing browser.

I created a quick projected test showing this behavior. here's a link to the download: https://drive.google.com/file/d/1wWPnSL ... sp=sharing
  1. on loaded test page in firefox browser, click one of the options in first group (click a second time if item doesn't get checked), this will cause page to reload and show the selected item.
  2. then click another option in second group, page will reload again and show the items that have been checked. although, at this point, it may already start displaying the wrong items checked.
  3. then click another option in third group, , page will reload again and show the items that have been checked. although, at this point, it may already start displaying the wrong items checked..
  4. then by unchecking them in reverse, when page reloads after each item is unchecked, other items returned as checked. in fact, when page reloads, try unchecking some of the returned checked items and you'll see that selections get all out of whack at this point.
  5. additionally, at this point, by just hitting the refresh button multiple times, you'll see that each time the page refreshes, different items return as checked.
does anyone have a clue what could be happening? is anyone else getting same behavior? thanks!!!
Last edited by eframsergio on 21 Sep 2022, 20:25, edited 2 times in total.

eframsergio
Posts: 46
Joined: 11 Jul 2019, 18:40

20 Sep 2022, 23:52

I found a similar issue in this post: https://stackoverflow.com/questions/419 ... in-firefox

The last suggestion mentions "adding explicit no-cache instructions to the HTTP-Header." in a filter

as a quick test, I set the suggested headers in the init method of my backing bean:

Code: Select all

    @PostConstruct 
    private void init() {
	HttpServletResponse httpServletResponse = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
	httpServletResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
	httpServletResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0.
	httpServletResponse.setDateHeader("Expires", 0); // Proxies.
	...
    }
and the issue went away.

So I guess I'll be setting up a filter as suggested.

Is this the right approach? Is there a more correct way of addressing this?

Thanks!

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

28 Sep 2022, 13:38

I use OmniFaces CacheControlFilter in ALL of my JSF apps and yes this is an OK approach. See: https://showcase.omnifaces.org/filters/ ... trolFilter
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

eframsergio
Posts: 46
Joined: 11 Jul 2019, 18:40

28 Sep 2022, 20:11

Thank you so much!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 31 guests