我将数据输入结果集并将其转换为RowSetDynaClass。我将Display标签中的RowSetDynaClass传递给显示列表。我也使用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。我该怎么办 我也尝试使用会话信息类,它具有相应的字段和getter以及setter方法,但仍然存在相同的错误。下面是会话信息类。
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;
}
}
答案 0 :(得分:0)
我使用BasicDynaBean类来获取当前行对象。
public String getGraph(){
// SessionInfo sessionData = (SessionInfo)getCurrentRowObject();
BasicDynaBean sessionData=(BasicDynaBean) getCurrentRowObject();
String showGraph = "<a href=\"javascript:send("+ sessionData.get("startdatetime")+","+ sessionData.get("enddatetime")+")\"> show graph </a>";
// String showGraph = "<a href=\"javascript:send()\"> show graph </a>";
return showGraph;
}