< h:selectOneListbox disabled = true导致NullPointerException [英] <h:selectOneListbox disabled=true causing NullPointerException
问题描述
我有JSF 1.1页面,其中我有一个< h:selectOneListbox
。当我设置属性disabled = true时,中的选定值< h:selectOneListbox
在提交页面时变为空。
I have JSF 1.1 page in which I have a <h:selectOneListbox
. When I set property disabled=true, selected value in <h:selectOneListbox
becomes null upon submitting the page.
<h:selectOneListbox size="1" id="prod" disabled="#{mybean.disable}"
如果将属性设置为disabled = true,我如何确保选中的值不为空。
How can I make sure value selected is not null even if property is set to disabled=true.
谢谢
推荐答案
当在HTML输入元素上设置禁用
属性时,那么它不仅是不可编辑的,而且还不将其name = value对作为请求参数发送到服务器。这就解释了为什么服务器为它们检索 null
。
When the disabled
attribute is set on a HTML input element, then it is not only uneditable, but it would also not send its name=value pair as request parameter to the server. That explains why the server retrieves null
s for them.
如果你想使它不可编辑,但仍然想要要将其name = value对作为请求参数发送到服务器,那么您应该使用 readonly
而不是。
If you want to make it uneditable, but still want to send its name=value pair as request parameter to the server, then you should be using readonly
instead.
<h:someInput ... readonly="true">
这篇关于< h:selectOneListbox disabled = true导致NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!