【问题标题】:Rich DataTable value selection issuesRich DataTable 值选择问题
【发布时间】:2015-09-06 04:11:07
【问题描述】:

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

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

我的用户界面代码..

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

【问题讨论】:

  • 你有什么问题?
  • 将错误的值传递给 bean
  • jsFunction是在dataTable里面还是外面? (我假设“info”是表中的一个变量)
  • 最有可能的 2 个操作是我们同步的:删除“当前”行并激活选定行。您可以使用 at 代码发布表格吗?

标签: jsf richfaces


【解决方案1】:

我猜这与“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}" 以确保我知道我正在编辑/删除哪一行

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多