p:selectOneRadio不使用p:ajax更新事件“更改”中的模型

时间:2023-01-26 20:02:36

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

我正在使用p:selectOneRadio和p:ajax以及另一个组件的值(p:inputText),而不是在我的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?

如果我使用p:selectBooleanCheckbox而不是行为正是我需要的,在调用ajax中的方法之前更新bean。这是p:selectOneRadio中的错误还是这是它的默认行为?

I'm using JSF2, PrimeFaces 4

我正在使用JSF2,PrimeFaces 4

The xhtml code:

xhtml代码:

 <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 个解决方案

#1


6  

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

摆脱event =“change”,这是错误的事件。它默认为单击并且已经是正确的。

<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.

单选按钮值永远不会改变。它们只能通过点击选择。反过来,提交选定的值,但未提供未选择的值。

#1


6  

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

摆脱event =“change”,这是错误的事件。它默认为单击并且已经是正确的。

<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.

单选按钮值永远不会改变。它们只能通过点击选择。反过来,提交选定的值,但未提供未选择的值。