Rich DataTable值选择问题

时间:2015-06-20 05:30:34

标签: jsf richfaces

我正在尝试删除数据表值。我的数据表显示了很多值。当我单击删除数据表中的特定行,然后打开确认对话框。如果单击okay然后调用bean并将该值删除到数据库。如果单击取消然后不调用bean ..这是我的功能..

例如: 我的数据表显示10行。当我选择1行删除按钮时,单击调用bean但它获取另一行值传递给bean ...

我的UI代码..

 <h:commandButton   image="/images/remove.png"  onclick="#    {rich:component('confirmation')}.show();return false"/>
<a4j:jsFunction name="submit" action="#{bean.delete}">
  <f:setPropertyActionListener target="#{bean.name}" value="#{info.name}" />
 </a4j:jsFunction>


   <rich:popupPanel id="confirmation" width="250" height="150">
   <f:facet name="header">confirmation</f:facet>
   <h:panelGrid>
   <h:panelGrid columns="2">
   <h:graphicImage value="/images/remove.png" />
  <h:outputText value="Are you sure?" style="FONT-SIZE: large;" />
  </h:panelGrid>
  <br></br> 
  <h:panelGroup >
  <center><input type="button" value="OK"
  onclick="#{rich:component('confirmation')}.hide();submit();return false"     />
 <input type="button" value="Cancel"
  onclick="#{rich:component('confirmation')}.hide();return false" />   </center>
</h:panelGroup>
</h:panelGrid>
</rich:popupPanel>

1 个答案:

答案 0 :(得分:0)

我想这与'AJAX调用不同步'

有关

发布的代码缺少表格信息,所以不要认为它与AJAX处理有关。

<rich:extendedDataTable
    id="myTable"
    value="#{myBean.rows}"
    selectionMode="single"
    rows="#{crudBean.actionForm.occurrences}"
    ...
    rowKeyVar="idx"
    ...>
    <a4j:ajax   event="selectionchange"
      listener="#{myBean.selectionListener}"/>
    <rich:column width="30px" styleClass="#{rowItem.className}">
      <util:myInputText id="status" managedBean="#{myBean}" rowItem="#{rowItem}" rowIndex="#{idx}"/>
    </rich:column>
      <util:myDeleteRecord id="delete" managedBean="#{myBean}" rowItem="#{rowItem}" rowIndex="#{idx}"/>
    </rich:column>
</rich:extendedDataTable>

在我的组件上,我使用: rowIndex =“#{idx}”,以确保我知道我正在编辑/删除哪一行