gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:42:46 25 4
gpt4 key购买 nike

我正在使用 p:selectOneRadiop:ajax和另一个组件的值( p:inputText ),没有在我的 bean 中绑定(bind)它的值。

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

我正在使用 JSF2,PrimeFaces 4

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>

最佳答案

摆脱event="change" ,这是错误的事件。默认为 click并且已经是正确的了。

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

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

关于ajax - :selectOneRadio not updating model in event "change" with p:ajax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21286545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com