データを結果セットに取得し、RowSetDynaClass に変換しています。この RowSetDynaClass を Display タグで渡し、リストを表示します。また、Decorator を使用して動的リンクを生成しています。以下はjspページのコードです...
<% RowSetDynaClass resultSetSearch = (RowSetDynaClass)request.getAttribute("rowSetSearchDyna"); %>
...
<display:table name="requestScope.resultSetSearch.rows" excludedParams="serialno status" pagesize="10" export="true" id="sessionresult"
class="displayTable" requestURI="" decorator="com.hpcfte.decorator.GraphLinkDecorator">
<display:column title="No."><%=pageContext.getAttribute("sessionresult_rowNum")%></display:column>
<display:column property="sessionid" href="graph" title="Sessionid" >
</display:column>
<display:column property="usercomment" title="Session Name" />
<display:column property="meterid" title="Meterid" />
<display:column format="{0,date,yyyy-MM-dd hh:mm:ss}" property="startdatetime" title="Start Date Time" />
<display:column format="{0,date,yyyy-MM-dd hh:mm:ss}" property="enddatetime" title="End Date Time" />
<display:column property="graph" title="Show Graph" />
<display:caption> Session Information </display:caption>
</display:table>
私のデコレータクラス
public String getGraph(){
// SessionInfo sessionData = (SessionInfo)getCurrentRowObject();
RowSetDynaClass sessionData=(RowSetDynaClass) getCurrentRowObject();
//String showGraph = "<a href=\"javascript:send("+sessionData.getStartDateTime()+","+sessionData.getEndDateTime()+")\"> show graph </a>";
String showGraph = "<a href=\"javascript:send()\"> show graph </a>";
return showGraph;
}
このコードはエラーを出します
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception: [.LookupUtil] Error looking up property "graph" in object type "com.hpcfte.decorator.GraphLinkDecorator". Cause: null
RowSetDynaClass sessionData=(RowSetDynaClass) getCurrentRowObject();
この行にコメントすると、正常に動作します。
デコレータ クラスで現在の行の startdatetime と enddatetime にアクセスしたいと考えています。どうすればいいですか。私はまた、対応するファイルとゲッターとセッターメソッドを持つセッション情報クラスを試しましたが、それでも同じエラーです。以下はセッション情報クラスです。
public class SessionInfo {
private String sessionId;
private String meterId;
private Date startDateTime;
private Date endDateTime;
private String userComment;
private boolean status;
public Date getEndDateTime() {
return endDateTime;
}
public void setEndDateTime(Date endDateTime) {
this.endDateTime = endDateTime;
}
public String getMeterId() {
return meterId;
}
public void setMeterId(String meterId) {
this.meterId = meterId;
}
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public Date getStartDateTime() {
return startDateTime;
}
public void setStartDateTime(Date startDateTime) {
this.startDateTime = startDateTime;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public String getUserComment() {
return userComment;
}
public void setUserComment(String userComment) {
this.userComment = userComment;
}
}