web.xml
[...]
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>false</param-value>
</context-param>
[...]
view.xhtml
[...]
<p:selectOneMenu id="input1" value="#{myBean.value1}">
<f:selectItem itemValue="" itemLabel="..." />
</p:selectOneMenu>
<p:inputText id="input2" value="#{myBean.value2}" />
[...]
MyBean.java
[...]
private String value1;
private String value2;
[...]
I leave input2
blank, submit the form and inspect the values in the managed bean:
value2
is an empty String - as expected!value1
is null
Why is value1
null and not an empty String? If I want the value to be an empty String, how can I achieve this?
Update
The "problem" is in the class com.sun.faces.renderkit.html_basic.MenuRenderer
:
public Object getConvertedValue(...) {
[...]
if (RIConstants.NO_VALUE.equals(newValue)) {
return null;
}
[...]
}