Convert empty number as null

2019-05-28 18:07发布

is there a possibility to tell my JSF-implementation to convert empty numbers as null. So far I always get 0 (of the corresponging complex-type).
For empty strings there is javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL, but I couldn't find anything for numbers. By the way: No, I can't use the vm-argument: -Dorg.apache.el.parser.COERCE_TO_ZERO=false

Is a custom-numberconverter my only possibility?

2条回答
Bombasti
2楼-- · 2019-05-28 18:50
叛逆
3楼-- · 2019-05-28 18:54

No, I can't use the vm-argument: -Dorg.apache.el.parser.COERCE_TO_ZERO=false

The problem is in EL implementation used by the server, not in JSF. You really need to use the VM argument. If you can't use it then your problem can't be solved by other way than downgrading Tomcat to 6.0.15 or older, or replacing the server by for example Glassfish. It was Tomcat 6.0.16 when this "improved" EL coercion behaviour was introduced.

If you elaborate the exact reason why you can't use it (it makes at least no sense to me), then we may be able to propose ways how to really use it. For example, if it's ignorance how to set a VM argument, then say so. Or if you're not allowed to add a VM argument to startup script because it's a 3rd party maintained server, then say so. Both problems can be solved so that you can use the VM argument rightly.

查看更多
登录 后发表回答