-
Notifications
You must be signed in to change notification settings - Fork 111
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
f:selectItem String null value #5190
Comments
This is Tomcat specific but it works for me with only Try reproducing the problem in e.g. WildFly or GlassFish. |
basically on Tomcat the After many headaches I found that the following ELResolver works as expected
|
ok |
on Wildfly 27.Final and GlassFish 7 it works as expected |
Probably there's more into your project which caused this to fail on your Tomcat deployment? E.g. wrong EL-related dependencies or configuration. |
mmm It's a minimal "playground" project where I test small things, this is Faces config inside web.xml:
I use the EL from Tomcat this is the pom
|
I was wrong, I accidentally tested the case with MyFaces instead of Mojarra. And it turns out that MyFaces has the "empty string to null" EL resolver installed by itself. For Mojarra you'll indeed have to supply your own. Detailed background info on this Tomcat behavior: https://balusc.omnifaces.org/2015/10/the-empty-string-madness.html I'll look at adding the EL resolver in Mojarra too. Noted should be that this doesn't affect specifically the h:selectOneMenu but all kinds of inputs. E.g. an empty h:inputText would incorrectly also set empty string instead of null when Tomcat is used. |
Add EmptyStringToNullELResolver to work around a misinterpreted change in EL3 spec
👍 👍
Yes, I've read your article many times! ... 😃 It's frustrating to see that after so many years there is still
🔝 Another solution is to fork Tomcat and modify ... Also @arjantijms would be happy to fork and add a getRequest method inside Tomcat request facade
Yes, exactly, I've reported the f:selectItem case because it's a classic example where the null String |
Closing off, was already merged. |
Add EmptyStringToNullELResolver to work around a misinterpreted change in EL3 spec
Describe the bug
It is not possible to send the null value with f:selectItem
when the backing bean property type is String
To Reproduce
Using the example at page 123 of "The definitive guide to Faces in Jakarta EE 10"
Expected behavior
When you submit the form choosing the first element of the select
the backing bean value should be null and not an empty String
Desktop (please complete the following information):
Stack
Faces 4.0
Tomcat 10.1.4
Jdk: 17.0.5
I also tried to replace the EL implementation with the Eclispe's one
but the result is the same (empty String instead of null value)
https://github.com/eclipse-ee4j/expressly
Additional context
There is a long story behind this (10+ years) on StackOverflow and on @BalusC blog
I tried all the solutions provided, and the problem is still on EL
because when you submit the null value:
is totally useless
I don't know which is the best place to solve this, I've implemented a naive solution using
a custom EL resolver like the one proposed by @BalusC but with a special String value which
I use as null, eg. 'faces.string.null'
Another solution could be to improve/fix/clarify one time and for all the f:selectItem
for example providing an attribute like 'nullValue' boolean indicating that Faces should
render a special String value that will be converted as null ... ?
The text was updated successfully, but these errors were encountered: