2012-07-27 60 views
0

我需要在struts2中添加/編輯/刪除對象表。當我提交表單時,我收到了重複的對象。索引屬性在表單提交時得到重複struts2

讓我知道我犯了什麼錯誤。

這是我的代碼:

<s:form action="addPromotionLineItems" id="promotionLineItemsAddFormId"> 
    <display:table id="data" 
     name="lstPromotionLineItems" sort="external" uid="row" htmlId="rowid" 
     class="tborder" excludedParams="*" style="width:100%" export="false"> 
     <display:column titleKey="table.title.material" style="width:100px"> 
      <s:property value="%{#attr.row.materialCode}" /> 
      <s:hidden 
       name="lstPromotionLineItems(%{#attr.row_rowNum-1}).promotionLineItemId" 
       value="%{#attr.row.promotionLineItemId}" /> 
      <s:hidden 
       name="lstPromotionLineItems(%{#attr.row_rowNum-1}).materialCode" 
       value="%{#attr.row.materialCode}" /> 
      <s:hidden 
       name="lstPromotionLineItems(%{#attr.row_rowNum-1}).material.description" 
       value="%{#attr.row.material.description}" /> 
      <s:hidden 
       name="lstPromotionLineItems(%{#attr.row_rowNum-1}).programId" 
       value="%{#attr.row.programId}" /> 
     </display:column> 
     <display:column property="material.description" 
      titleKey="table.title.materialdesc" /> 

</s:form> 



function refreshTableRecords(url,formNameId,resultId) 
    $.ajax({ 
     type:'POST', 
     url: url, 
     data:$('#'+formNameId).serialize(), 
     success : function(response) { 
      $('#'+resultId).html(response); 
      }, 
      error:function(data) 
      { 
       alert(data); 
      } 
     }); 
} 

我在jQuery用戶界面模式彈出此內容。

+0

你能描述一下你的意思嗎? – 2012-07-27 09:54:35

+0

什麼信息顯示在第0指數,當我提交的行動,我得到的是在第一,一個指數的位置。 – Jothi 2012-07-27 11:57:16

回答

0

我認爲在struts映射到採集數據時,語法是不是:

name="lstPromotionLineItems(%{#attr.row_rowNum-1}).promotionLineItemId" 

而:

name="lstPromotionLineItems[%{#attr.row_rowNum-1}].promotionLineItemId" 

有圍繞ROW_NUM屬性中輸入名稱包圍的微小差異。