It seems that changing the state of a p:selectBooleanCheckbox to 'checked' from JS doesn't work anymore. More precisely, although the value of the underlying HTML element , the hidden input, does change, the appearance on the page does not (the CSS doesn't change to show the UI as 'checked').
I've tried both ways:
- to directly grab the real checkbox HTML input via document.getElementById() and do cboxEl.checked = true;
- to use the widget client side API and call widget.check();
Same happens for p:selectManyCheckbox.
I also tried to run a JS snippet against the official PF demo page, same result.
PF 8.0.4.
Payara 4.1
Chrome/Edge
Change selectBooleanCheckbox from JS
Works for me?
Go here: https://www.primefaces.org/showcase/ui/ ... kbox.xhtml
Press F12 and open Chrome Console and type..
it checks the Basic box for me?
Go here: https://www.primefaces.org/showcase/ui/ ... kbox.xhtml
Press F12 and open Chrome Console and type..
Code: Select all
PrimeFaces.widgets.widget_j_idt725_j_idt727.check();
it checks the Basic box for me?
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
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
-
- Posts: 13
- Joined: 09 Oct 2013, 16:41
I'll take back the widget.check() related comment, it is working, sorry for the confusion.
Now, on the same page, trying
has no visual effect. I'm pretty I used this in PF 6.x and it was working. I'm trying to directly use the element to init the value the via a JS snippet part of a reusable form and work around the widgets not being available at that moment (before the full page load).
Now, on the same page, trying
Code: Select all
document.getElementById('j_idt725:j_idt727_input').checked=true;
Hmmm looking at the code I am not sure if this worked. Looking back through Git it has been this way since PF 6.2, 7.0, 8.0 as far as I can tell.
How far back in PF did you know that it worked? What PF version?
How far back in PF did you know that it worked? What PF version?
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
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
-
- Posts: 13
- Joined: 09 Oct 2013, 16:41
It may have been PF 6.0. or 6.1, I just jumper directly to 8.0.
This was an old form we had deployed in 2017 and was accepted as working (more precisely, it was a p:selectManyCheckbox and i would iterate and set the individual checkboxes). I just realized these days, when trying to add a separate checkbox, that the old stuff it doesn't work anymore.
Thanks for the quick feedback!
This was an old form we had deployed in 2017 and was accepted as working (more precisely, it was a p:selectManyCheckbox and i would iterate and set the individual checkboxes). I just realized these days, when trying to add a separate checkbox, that the old stuff it doesn't work anymore.
Thanks for the quick feedback!
OK then i recommend updating your code. My guess is between 6.0 and 8.0 that functionality was removed because of some other feature or bug fix etc.
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
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
-
- Posts: 13
- Joined: 09 Oct 2013, 16:41
While I can work around it for this particular case, I think the question about the expected behavior still remains. I mean, it's a fair assumption that by modifying the underlying DOM element, the change should be visible in the wrapping PF component/UI? Currently the UI gets out of sync. Also, the onchange doesn't fire either when.
I don't think you should be manipulating an underlying hidden DOM Input. You should be interacting with the widget right?
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
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
-
- Posts: 13
- Joined: 09 Oct 2013, 16:41
Well, I can't totally disagree, but it's a debatable thing. I'll move on with a different approach.
Thanks!
Thanks!
-
- Information
-
Who is online
Users browsing this forum: No registered users and 23 guests