PrimeFaces extensions - empty value attribute

久未见 提交于 2019-12-10 17:21:05

问题


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?


回答1:


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>

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


来源:https://stackoverflow.com/questions/14607439/primefaces-extensions-empty-value-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!