I have viewprofile
action that displays the user's details and transaction history.
History.java
:
public class History {
private String transactionId;
private Date transactionDate;
private String movieTitle;
private BigDecimal schedulePrice;
private String mallName;
private int scheduleCinema;
private Date scheduleDate;
private Time scheduleTime;
// getters and setters
}
ViewProfileAction.java
:
public class ViewProfileAction extends ActionSupport implements SessionAware, RequestAware {
private static final long serialVersionUID = 1L;
private Map<String, Object> session;
private Map<String, Object> request;
@Override
public String execute() throws Exception {
if(!session.containsKey("currentUserId")) {
return "index"; // return to index if not logged in
}
String currentUserId = (String) session.get("currentUserId");
UserManager um = new UserManager();
String registeredUserEmail = um.getCurrentUserDetail("user_email", currentUserId);
Date registeredDate = um.getRegisteredDate(currentUserId);
int totalTransactions = um.getTotalTransactions(currentUserId);
List<History> historyList = new DatabaseManipulator().getTransactionHistory(currentUserId);
request.put("registeredUserEmail", registeredUserEmail);
request.put("registeredDate", registeredDate);
request.put("totalTransactions", totalTransactions);
request.put("historyList", historyList);
return SUCCESS;
}
@Override
public void setSession(Map<String, Object> session) {
this.session = session;
}
@Override
public void setRequest(Map<String, Object> request) {
this.request = request;
}
}
user-profile.jsp
:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<body>
<table class="displaytbl">
<tr>
<td class="maintitle" colspan="7">TRANSACTION HISTORY</td>
</tr>
<tr>
<!-- column titles -->
</tr>
<c:choose>
<c:when test="${historyList.isEmpty()}">
<tr>
<td class="norecord" colspan="7">NO RECORDED TRANSACTIONS</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach var="history" items="historyList">
<tr>
<td>${history.transactionDate}</td>
<td>${history.movieTitle}</td>
<td>${history.schedulePrice}</td>
<td>${history.mallName}</td>
<td class="center">${history.scheduleCinema}</td>
<td>${history.scheduleDate}</td>
<td>${history.scheduleTime}</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</table>
</body>
struts.xml
:
<action name="viewprofile" class="com.mypackage.action.ViewProfileAction">
<result>/user-profile.jsp</result>
<result name="index" type="redirect">/index.jsp</result>
</action>
StackTrace:
javax.el.PropertyNotFoundException: Property 'transactionDate' not found on type java.lang.String
I am not sure why it is throwing PropertyNotFoundException
when I do have the said property in History
. How to resolve such issue?