电话号码:selectOneRadio不更新模型,事件和QUOT;变"与号码:阿贾克斯电话号码、模型、号码、事件

2023-09-10 19:48:53 作者:郁眠

我使用的是号码:selectOneRadio 号码:AJAX 和另一个组件的值(号码:inputText的),没有约束它的价值在我的豆

如果我用号码:selectBooleanCheckbox 而不是行为正是我所需要的,调用AJAX方法之前更新豆。这是 P A错误:?selectOneRadio 或者是这个它的默认行为

我使用的 JSF2 的 PrimeFaces 4 的

在 XHTML code:

 <电话号码:selectOneRadio ID =enumId值=#{xyzCont​​roller.entity.enumValor}
    禁用=#{禁用}要求=真正的纯=真正的>
    < F:selectItems的值=#{xyzCont​​roller.enum}VAR =项
        itemLabel =#{消息[ELUtils.evaluateEx pression(itemLabelEL)]}
        itemValue =#{}项/>
    <电话号码:AJAX事件=变监听器=#{xyzCont​​roller.aoTrocar}
        更新=panelDominioFields过程=@形式/>
< / P:selectOneRadio>

<电话号码:outputPanel布局=内联ID =panelDominioFields>
    <电话号码:inputText的ID =valorId
        值=#{xyzCont​​roller.entity.valorNumericoValido}
        渲染=#{xyzCont​​roller.mostrarCampoDominioNumerico}
        所需=真正的>
        < F:convertNumber类型=数字区域设置=#{localeController.locale}
            货币code =#{localeController.currency code}/>
    < / P:inputText的>
< / P:outputPanel>
 

解决方案

摆脱事件=改变,这是错误的事件。它默认为点击,是正确的了。

 <电话号码:阿贾克斯监听=#{xyzCont​​roller.aoTrocar}
    更新=panelDominioFields过程=@形式/>
 
你的密码已经多久没改了 那就在今天改掉吧

单选按钮值永远不会改变。他们只选择的由点击。反过来,选择的值被提交,但未被选择的值不是。

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>

解决方案

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.