0

我想显示一个省略号作为评论的链接。然后当用户点击省略号时,完整的评论会显示在模态面板中。如果评论超过 8 个字符,则显示省略号。

它工作正常,只是没有显示适当的评论……例如……第二条评论显示在第一条评论中,依此类推。我在模态面板中打印了 rowIndex,它从 1 开始表示第一行,从 2 开始表示第二行数据,依此类推。

请帮助我在模态面板中获得正确的评论。

以下部分是具有 var="row" rowKeyVar="rowIndex" 的丰富扩展数据表

<rich:column sortable="true" width="13%">
    <f:facet name="header">
        <h:outputText value="#{msg.COMMENTS}" escape="false" />
    </f:facet>

   <!-- Start : change to add ellipsis for long comments -->                                
   <h:outputText value="#{not empty row.comments or fn:length(row.comments) gt 10 ? fn:substring(row.comments, 0, 8) : row.comments}" />

  <a4j:commandLink id="descriptionLink" value="#{not empty row.comments or fn:length(row.comments) gt 8 ? '...' : ' '}"
    onclick="showProgressLoader();"                                     
    oncomplete="Richfaces.showModalPanel('popup');hideProgressLoader();"
    style="font-size: 10pt;font-weight: bold;"
    reRender="popup">
  </a4j:commandLink>

 <rich:modalPanel id="popup" resizeable="true">  
    <f:facet name="header">  
        <h:outputText id="description" value="Full Comment" /> 
    </f:facet>  
    <f:facet name="controls">  
    <h:graphicImage value="/images/delete.png" style="cursor:pointer" onclick="#{rich:component('popup')}.hide()" height="10px" width="10px"/>  
        </f:facet>  
            <p>  
                #{row.comments} #{rowIndex}
            </p>  
  </rich:modalPanel>                                    
</rich:column>
<!-- End : change to add ellipsis for long comments -->
4

1 回答 1

0

您可以将面板放在表格之外,而不是每行有一个面板。当您单击按钮时,您将所选项目保存在 bean 中,然后重新渲染面板以显示正确的项目,例如:

<a4j:commandLink … 
     onclick="bean.setSelectedItem(row)"
     oncomplete="Richfaces.showModalPanel('popup');" />

<rich:modalPanel id="popup" resizeable="true">
    …
    #{bean.selectedItem.comment}
</rich:modalPanel>
于 2019-11-26T16:56:59.893 回答