Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p:selectOneRadio not updating model in event "change" with p:ajax

I'm using an p:selectOneRadio with p:ajax and the value of another component (p:inputText), not binding its value in my bean.

If I use p:selectBooleanCheckbox instead the behavior is exactly what I need, update the bean before calling the method in ajax. Is this a bug in p:selectOneRadio or is this its default behavior?

I'm using JSF2, PrimeFaces 4

The xhtml code:

 <p:selectOneRadio id="enumId" value="#{xyzController.entity.enumValor}"
    disabled="#{disabled}" required="true" plain="true">
    <f:selectItems value="#{xyzController.enum}" var="item"
        itemLabel="#{messages[ELUtils.evaluateExpression(itemLabelEL)]}"
        itemValue="#{item}" />
    <p:ajax event="change" listener="#{xyzController.aoTrocar}"
        update="panelDominioFields" process="@form" />
</p:selectOneRadio>

<p:outputPanel layout="inline" id="panelDominioFields">
    <p:inputText id="valorId"
        value="#{xyzController.entity.valorNumericoValido}"
        rendered="#{xyzController.mostrarCampoDominioNumerico}"
        required="true">
        <f:convertNumber type="number" locale="#{localeController.locale}"
            currencyCode="#{localeController.currencyCode}" />
    </p:inputText>
</p:outputPanel>
like image 913
Leandro Andrade Avatar asked Jan 22 '14 15:01

Leandro Andrade


1 Answers

Get rid of event="change", it's the wrong event. It defaults to click and is the right one already.

<p:ajax listener="#{xyzController.aoTrocar}"
    update="panelDominioFields" process="@form" />

Radio button values never change. They're only selected by click. In turn, selected values are submitted, but unselected values not.

like image 153
BalusC Avatar answered Nov 17 '22 23:11

BalusC