テーブルで選択した行を強調表示する方法を見つけようとしています。私のjspには、displaytagライブラリが作成している行のIDにアクセスできるjspスクリプトレットがあります。ユーザー ${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 のようにハードコーディングされていない限り、どこにも見つかりません。
ご協力いただきありがとうございます。