PrimeFaces扩展-空值属性 [英] PrimeFaces extensions - empty value attribute
问题描述
在我的页面上,我有<pe:inputNumber>
,它指的是非必填字段.如果我将其保留为空,则即使我设置了emptyValue = ""
,它也会将该值设置为0.如果该组件无法为我提供该功能,该怎么办或应该使用什么?
On my page, I have <pe:inputNumber>
which refers to a not mandatory field. If I leave it empty, it sets the value to 0 even if I set emptyValue = ""
. What should I do or what should I use, if this component cannot offer me that functionality?
推荐答案
您可能需要专门指示JSF将空输入字段解释为null,以免使用context-param将其强制为"0"
You might need to specifically instruct JSF to interpret empty input fields as null as against coercing it to "0" with the context-param
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
此外,对于基于tomcat构建的容器(JBoss,WSphere等),您应该设置以下JVM config属性(在IDE中非常容易做到)
Additionally, for a container built on tomcat (JBoss, WSphere etc), you should set the following JVM config property (pretty easy to do within an IDE)
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
这篇关于PrimeFaces扩展-空值属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!