2015-11-09 64 views
0

我有一张使用@for组件生成的表格。 表中的一列包含一个直接链接,该链接调用方法并向表源添加更多行。挂毯:update @for on directLink

现在我想要做的就是在UI上刷新此表。 它工作正常,如果我刷新整个页面。但是当我在directlink上使用updateComponent标记时。我只看到1排。我的理解是,我的组件是连续的,这就是为什么只有一行正在更新。

你可以建议,我怎么才能更新整个表格。 我试着把@for放在说tbody上,但那不行。

代码:

<div id="compFeeTableDiv" jwcid="[email protected]" style="visibility: hidden"> 
    <fieldset> 
     <legend> 
     </legend> 
     <table height="100%" cellSpacing="2" cellPadding="2" width="100%" border="0" id="compFeeTable"> 
      <thead> 
       <tr> 
        <th> 
         <span key="abc" /> 
        </th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr jwcid="@For" source="ognl:compFees" value="ognl:compFee" element="tr" index="ognl:loopIndex"> 
        <td valign="center" align="center" height="15" class="listlabel2"> 
         <span jwcid="@If" condition="true"> 
          <div jwcid="@Any"> 
           <a href="" jwcid="@DirectLink" name="ognl:'edit_link_'" listener="listener:newCompFee" size="5"> 
            <img src="images/addAction.png" alt="addAction"> 
           </a> 
          </div> 
         </span> 
        </td> 
       </tr> 
      </tbody> 
     </table> 
    </fieldset> 
</div> 

备份的Java侦听器方法

public void newcompFee(IRequestCycle cycle) { 
    compFee newcompFee = compFeeFactory.createDefaultcompFee(null,getAgent().getCompany()); 
    List<compFee> compFees = getcompFees(); 
    compFees.add(newcompFee); 
    setcompFees(compFees); 
    getAgent().getCompany().setcompFeeApplicable(YesNo.Yes); 
} 

我曾尝试上直接连结的updateComponent属性并将其指向我@for的ID。但刷新后只能呈现1行。

我正在使用tapestry 4.1.6。

请指教。 谢谢

+1

''未关闭 – Tushar

+0

@Tushar:感谢您指出了这一点。修复。 –

+0

@Tushar。事实证明..不关闭是问题。我关闭了。现在我可以使用directlink上的'updateComponent'属性刷新whoole div。谢谢。我会发布一个答案。 –

回答

0

所以。 这个问题真的很愚蠢。正如@Tusar在他的评论中指出的那样。这是因为<thead>未关闭。

什么工作对我来说:

<div id="compFeeTableDiv" jwcid="[email protected]" style="visibility: hidden"> 
<fieldset> 
     <legend> 
     </legend> 
     <table height="100%" cellSpacing="2" cellPadding="2" width="100%" border="0" id="compFeeTable"> 
      <thead> 
       <tr> 
        <th> 
         <span key="abc" /> 
        </th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr jwcid="@For" source="ognl:compFees" value="ognl:compFee" element="tr" index="ognl:loopIndex"> 
        <td valign="center" align="center" height="15" class="listlabel2"> 
         <span jwcid="@If" condition="true"> 
          <div jwcid="@Any"> 
           <a href="" jwcid="@DirectLink" name="ognl:'edit_link_'" listener="listener:newCompFee" size="5" updateComponent="compFeeTableDivTap"> 
            <img src="images/addAction.png" alt="addAction"> 
           </a> 
          </div> 
         </span> 
        </td> 
       </tr> 
      </tbody> 
     </table> 
    </fieldset> 
</div> 

所以基本上,我呼吁直接连结的updateComponent封闭格。完美的作品。

UPDATE 纠正后。整个页面正在刷新。 这里的问题是updateComponent中有一个错字。这应该是updateComponents

所有完美的作品现在