Strange behaviour of selectOneMenu

UI Components for JSF
Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

21 Jul 2021, 13:40

Sounds like your validator is somehow munging it? Like the validator is failing and thus the old value remains.
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

Marco Sulla
Posts: 25
Joined: 16 Jun 2021, 16:48

21 Jul 2021, 14:05

But a validator should NOT act like this.... this is the ONLY validator that does not works. The code is wrong?

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

21 Jul 2021, 14:29

I would assume since if you remove the validator the code works fine. So it sounds like the bug is somewhere in this validator.
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

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

21 Jul 2021, 14:43

Also did you see the answer on StackOverflow: https://stackoverflow.com/questions/684 ... -not-rende

I was going to suggest the same thing I don't know why you even need this validator?
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

Marco Sulla
Posts: 25
Joined: 16 Jun 2021, 16:48

21 Jul 2021, 14:50

The answer does not work, I'll write there why.

Why I need a Validator? Well, why you need int? :D
I need a Validator because I want to be sure that the user has done a choice in a SelectOneMenu, and I can't find a way to do it. It's the scope of validators, check if the value of an input is correct.

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

21 Jul 2021, 15:02

Why not just use required="true" and requiredMessage="A value is required" or whatever you want it to say?
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

Marco Sulla
Posts: 25
Joined: 16 Jun 2021, 16:48

21 Jul 2021, 18:46

Because I have to repeat `requiredMessage="A value is required"` for every input. But what if the message changes? This is against the One Source of Truth.

Is there not a way to change the message globally by default?

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

21 Jul 2021, 19:20

Yep i believe you can configure that with a JSF Message Bundle property globally.
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

Marco Sulla
Posts: 25
Joined: 16 Jun 2021, 16:48

23 Jul 2021, 11:08

Ok, this is my solution:

https://stackoverflow.com/a/68483393/1763602

but the problem is that, if I select an option and then back the noSelectionOption, the wrapper does NOT update.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 58 guests