简体   繁体   English

f:ajax无法在ui:repeat中对h:selectOneRadio正常工作

[英]f:ajax not working as expected for h:selectOneRadio inside ui:repeat

I am rendering a table with , which has a radio button. 我正在使用渲染表格,其中有一个单选按钮。 ie , on selection of radioButton, need to re-render the whole form. 即,在选择radioButton时,需要重新渲染整个表单。 but which is not working. 但是这不起作用。

Here is my code: 这是我的代码:

<h:form id="summaryForm" prependId="false">
<table>
<tbody>
  <ui:repeat var="switchRow" value="#{designBean.switchReport.rowList}" varStatus="rowStatus">
     <tr class="#{rowStatus.even?'even':'odd'}">
      <td>
     <h:selectOneRadio id="switchTypeSelectionId" 
                  name="switchTypeSelection" 
              styleClass="choices"
              onclick="selectRadioButton(this);"
              value="#{designBean.designTool.switchProduct}">
      <f:selectItem itemValue="#{switchRow.rowId}"/>
      <f:ajax event="click" execute="@this" render="@form" listener="#{designBean.showIGBTDetails}"/>
    </h:selectOneRadio>
    </td>
    <ui:repeat var="switchColValue" value="#{switchRow.rowValues}">
        <td>
                    <h:outputText value="#{switchColValue}" /> 
                </td>
    </ui:repeat>
      </tr>
     </ui:repeat>
</tbody>
</table>
</h:form>

I don't know if a click event is what you need in this case. 在这种情况下,我不知道您是否需要单击事件。 Try using onchange. 尝试使用onchange。 I remember something that mentioned this in the past. 我记得过去曾经提到过的事情。 However it wont fire if you click multiple times on the already selected radio item. 但是,如果您在已选择的单选项目上单击多次,则不会触发。

Also, did you try using the id of the form instead @form? 另外,您是否尝试使用表单的ID而不是@form? Like render="summaryForm". 就像render =“ summaryForm”。

After some research, i found a simple way to achieve this, Here is my answer, instead of using h:selectOneRadio, changed it to HTML and wrapped it in a , now the click on panelGrid component calling the ajax function/listener. 经过研究,我找到了一种简单的方法来实现这一目标,这是我的答案,而不是使用h:selectOneRadio,将其更改为HTML并将其包装在a中,现在单击panelGrid组件即可调用ajax函数/监听器。

<h:form id="summaryForm" prependId="false">
<table>
<tbody>
  <ui:repeat var="switchRow" value="#{designBean.switchReport.rowList}" varStatus="rowStatus">
     <tr class="#{rowStatus.even?'even':'odd'}">
      <td>
          <h:panelGrid id="switchSelectionId" styleClass="choices">
                <input type="radio" name="switchTypeSelection" value="#{switchRow.rowId}" />
                <f:ajax event="click" execute="@this" render="@form" listener="#{designBean.showIGBTDetails}"/>
          </h:panelGrid>
      </td>
      <ui:repeat var="switchColValue" value="#{switchRow.rowValues}">
        <td>
             <h:outputText value="#{switchColValue}" /> 
        </td>
      </ui:repeat>
      </tr>
     </ui:repeat>
</tbody>
</table>
</h:form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM