我有两个单选按钮,默认情况下没有选中任何一个,并且必须选择其中一个,所以这就是我所做的:
<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>
Run Code Online (Sandbox Code Playgroud)
该selectedPaymentMethod
属性是一个字符串,其默认值为null
而credit_inputs_fragment是一个包含div的ui:fragement
问题:点击单选按钮时,要更改的两个片段不受影响.
请指教,谢谢.
您在描述具体问题时并不完全清楚,但到目前为止我发现的代码中至少有两个潜在的问题:
对于<f:ajax event="change">
radiobuttons和复选框,这是错误的.它应该是event="click"
.或者,更好的是,完全删除它.它已经默认为正确的.另请参见我可以将哪些值传递给f:ajax标记的event属性?
引用的组件<f:ajax render>
必须是一个完整的JSF UI组件,并始终呈现给客户端.如果组件本身从未呈现给HTML,那么JavaScript根本无法找到它来更新其内容.您基本上需要在另一个始终呈现的组件中有条件渲染的组件.另请参阅当我想要更新ajax时,为什么我需要在另一个组件中嵌套一个带有rendered ="#{some}"的组件?
归档时间: |
|
查看次数: |
19551 次 |
最近记录: |