我一直在试图弄清楚如何突出显示表格中的选定行。在我的 jsp 中,我有 jsp scriplet 可以访问 displaytag 库正在创建的行的 id。我想将它与用户 ${currentNoteId} 选择的当前行的 id 进行比较。现在,如果行 id = 849(硬编码),则将类“currentClass”添加到表的该行中。我需要为 {$currentNoteId} 更改 849,但我不知道该怎么做。我正在使用java,Spring MVC。jsp:...
<%
request.setAttribute("dyndecorator", new org.displaytag.decorator.TableDecorator()
{
public String addRowClass()
{
edu.ilstu.ais.advisorApps.business.Note row =
(edu.ilstu.ais.advisorApps.business.Note)getCurrentRowObject();
String rowId = row.getId();
if ( rowId.equals("849") ) {
return "currentClass";
}
return null;
}
});
%>
<c:set var="currentNoteId" value="${studentNotes.currentNote.id}"/>
...
<display:table id="noteTable" name="${ studentNotes.studentList }" pagesize="20"
requestURI="notesView.form.html" decorator="dyndecorator">
<display:column title="Select" class="yui-button-match" href="/notesView.form.html"
paramId="note.id" paramProperty="id">
<input type="button" class="yui-button-match2" name="select" value="Select"/>
</display:column>
<display:column property="userName" title="Created By" sortable="true"/>
<display:column property="createDate" title="Created On" sortable="true"
format="{0,date,MM/dd/yy hh:mm:ss a}"/>
<display:column property="detail" title="Detail" sortable="true"/>
</display:table>
...
这也可以使用 javascript 来完成,这可能是最好的,但文档建议这样做,所以我想我会尝试一下。我在任何地方都找不到使用 addRowClass() 的示例,除非比较的是行中已经存在的字段(文档示例中使用了美元金额)或硬编码为“849”id。
感谢您的任何帮助,您可以提供。