繁体   English   中英

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

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

我正在使用渲染表格,其中有一个单选按钮。 即,在选择radioButton时,需要重新渲染整个表单。 但是这不起作用。

这是我的代码:

<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>

在这种情况下,我不知道您是否需要单击事件。 尝试使用onchange。 我记得过去曾经提到过的事情。 但是,如果您在已选择的单选项目上单击多次,则不会触发。

另外,您是否尝试使用表单的ID而不是@form? 就像render =“ summaryForm”。

经过研究,我找到了一种简单的方法来实现这一目标,这是我的答案,而不是使用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