h:selectOneRadio不适用于ajax更改事件

编程入门 行业动态 更新时间:2024-10-28 20:28:14
本文介绍了h:selectOneRadio不适用于ajax更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个单选按钮,默认情况下没有一个被选中,并且必须选择其中一个,所以这就是我所做的:

i have two radio buttons and no one is selected by default, and it's mandatory to select one of them, so here's what i did:

<div id="payment_method"> <h:message for="sel_payment_method" style="Color:red;"/> <h:selectOneRadio id="sel_payment_method" required="true" requiredMessage="Please select a payment method" value="#{myBean.selectedPaymentMethod}"> <f:selectItem itemLabel="Debit or Credit Card" itemValue="credit" /> <f:selectItem itemLabel="Checking Account" itemValue="checking" /> <f:ajax event="change" render="credit_inputs_fragment checking_inputs_fragements" /> </h:selectOneRadio> </div>

selectedPaymentMethod属性是一个字符串,其默认值为null

the selectedPaymentMethod property is a string and its default value is null

和 credit_inputs_fragment 是包含div的ui:fragement

and the credit_inputs_fragment is a ui:fragement that contains a div

问题:单击单选按钮时,两个要更改的片段不受影响.

ISSUE: when clicking on a radio buttons the two fragments to be changed are not affected.

请告知,谢谢.

推荐答案

您在描述具体问题上并不十分清楚,但是到目前为止,我在代码中至少看到了两个潜在问题:

You're not entirely clear in describing the concrete problem, but I can see at least two potential problems in the code posted so far:

  • 对于单选按钮和复选框,<f:ajax event="change">是错误的.它应该是event="click".或者,更好的是,将其完全删除.它默认为正确的一个.另请参见我可以将哪些值传递给f:ajax标记的事件属性?

  • The <f:ajax event="change"> is wrong in case of radiobuttons and checkboxes. It should be event="click". Or, better, just remove it altogether. It defaults to the right one already. See also What values can I pass to the event attribute of the f:ajax tag?

    <f:ajax render>中引用的组件必须是完全有价值的JSF UI组件,并且总是呈现给客户端.如果组件本身从未呈现为HTML,则JavaScript根本找不到它来更新其内容.基本上,您需要在始终渲染的另一个组件中有条件渲染的组件.另请参见为什么需要嵌套带有render ==#{some}"的组件?在另一个组件中,当我想对其进行ajax更新时?

    The component referenced in <f:ajax render> must be a fullworthy JSF UI component and always be rendered to the client side. If the component is by itself never rendered to the HTML, then JavaScript simply can't find it to update its content. You basically need the conditionally rendered components in another component which is always rendered. See also Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?

  • 更多推荐

    h:selectOneRadio不适用于ajax更改事件

    本文发布于:2023-11-24 21:39:54,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1626942.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:不适用于   事件   selectOneRadio   ajax

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!