h:selectOneMenu with EnumConverter are updating to null value

386 views Asked by At

In the example below, the converter works correctly when the form is submitted. However, when attempting to perform any actions in the event 'onchange', the value of type 'enum' is changed to null. After several attempts and research, using valueChangeListener, onchange = "submit()" and immediate = "true", nothing resolved.

Enum

public enum TipoGasCondicaoUsoPermeacao {

    CONCENTRACOES("Concentrações"),
    FUGACIDADES("Fugacidades"),
    PRESSOES_PARCIAIS("Pressões parciais");

    private String label;

    private TipoGasCondicaoUsoPermeacao(String label) {
        this.label = label;
    }

    /**
     * @return the descricao
     */
    public String getLabel() {
        return this.label;
    }
}

XHTML

<h:selectOneMenu value="#{condicaoUso.tipoGasCondicao}" required="false" styleClass="field_form medio">
    <f:selectItems value="#{listaMB.tiposGasCondicoesUso}" id="itemTipoGas" />
    <a4j:support event="onchange" oncomplete="dadosAlterados(true)" reRender="otherPanel" />
</h:selectOneMenu>

faces-config.xml

 <converter>
  <converter-for-class>java.lang.Enum</converter-for-class>
  <converter-class>javax.faces.convert.EnumConverter</converter-class>
 </converter>
1

There are 1 answers

0
Pereira On

The problem persisted until I used the property ajaxSingle="true" (default is 'false'), as shown below:

<a4j:support event="onchange" oncomplete="dadosAlterados(true)" reRender="otherPanel" ajaxSingle="true" />

Magic?