"jsf 2.0 - selectonemenu defaults to 0 when empty" Code Answer

4

this converter is unnecessary and makes no sense (i'd expect an userconverter to convert between user and string, not between long and string). remove it.

now, you need to tell jsf to interpret empty string submitted values as null. add the following to your web.xml:

<context-param>
    <param-name>javax.faces.interpret_empty_string_submitted_values_as_null</param-name>
    <param-value>true</param-value>
</context-param>

this should solve the problem on most containers. but if you're using tomcat or a fork/clone of it (jboss as, websphere as, etc) and/or the container uses the apache el parser implementation, then you also need to add the following argument to its vm startup arguments:

-dorg.apache.el.parser.coerce_to_zero=false

this will prevent the apache el parser from coercing the submitted value to the primitive's default, even though you're using a primitive wrapper type as property.

see also:

  • communication in jsf 2.0

unrelated to the concrete problem, you don't have a combobox there. that's just a simple dropdownlist. a combobox is an editable dropdownlist. get your terms right ;)

By Peter Moore on March 16 2022

Answers related to “jsf 2.0 - selectonemenu defaults to 0 when empty”

Only authorized users can answer the Search term. Please sign in first, or register a free account.