p:selectOneRadio not updating model in event “change” with p:ajax

大兔子大兔子 提交于 2019-12-19 19:07:12

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/21286545/pselectoneradio-not-updating-model-in-event-change-with-pajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!