📄 stockdetails.jsp
字号:
<%--
* @author Pushkala
* @version 1.0
*
* Development Environment : Oracle9i JDeveloper
*
* Name of the File : StockDetails.jsp
*
* Creation/Modification History :
* Pushkala 26-Apr-2002 Created
*
* Overview of Application :
*
* This page is part of the IBFBS application.
* This page displays the Portfolio Details of the stock held by the logged in user.
* The user can navigate to this page by clicking the Portfolio tab in the header.
*
--%>
<%@page contentType="text/html;charset=WINDOWS-1252" language="java" %>
<%@page import="oracle.otnsamples.ibfbs.trademanagement.ejb.PortfolioValue" %>
<%@page import="oracle.otnsamples.ibfbs.usermanagement.ejb.AccountInfo" %>
<%@page import="oracle.otnsamples.ibfbs.trademanagement.helper.DateFormatter" %>
<%@page import="oracle.otnsamples.ibfbs.utils.FormatUtils" %>
<%@page import="java.util.Collection" %>
<%@page import="java.util.Iterator" %>
<%@page import="java.util.HashMap" %>
<html>
<head>
<title>OTN Financial Brokerage System : Portfolio Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=WINDOWS-1252">
<link rel="stylesheet" href="includes/contents.css" type="text/css">
<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
<!--
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='includes/tab.js' TYPE='text/javascript'><\/SCRIPT>");
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
// Function to set the value of recordnumber which is required for page formatting
function setRecordNum(recNum) {
formObj = document.PAGEFORMAT;
formObj.RECORDNUM.value = recNum;
formObj.submit();
}
</SCRIPT>
</head>
<body bgcolor="#FFFFEA" onLoad="MM_preloadImages('images/myhome.gif','images/profile.gif','images/personalize.gif','images/portfolio.gif','images/logout.gif')">
<jsp:include page="Header.jsp?TABIMAGE=portfolio.gif" flush="TRUE"/>
<%
String tab = request.getParameter("EVENTNAME");
// When the user clicks the Portfolio tab in the header, the event 'PORTFOLIO' is sent to the
// controller servlet which maps the event with this page using the mapping in control.xml file.
if (tab.equals("PORTFOLIO")) {
// If the EVENTNAME is PORTFOLIO, get the Portfolio response value into the Hashmap
java.util.HashMap hm = (java.util.HashMap) session.getAttribute("PORTFOLIO.RESPONSE");
Collection retCollection = (Collection)hm.get("PORTFOLIOVALUATION");
Iterator retIter = retCollection.iterator();
String hasPrev = "false";
String hasNext = "false";
Collection pfCollection = null;
String totalAssetValue = "0";
if (retIter.hasNext()) {
hasPrev = (String)retIter.next();
hasNext = (String)retIter.next();
pfCollection = (Collection)retIter.next();
totalAssetValue = FormatUtils.formatFloatToString(((Float)retIter.next()).floatValue());
}
// Record Number of the first record in the set displayed
String recordNum = request.getParameter("RECORDNUM");
// Get the Account information of the logged in user
AccountInfo acInfo = (AccountInfo)hm.get("ACCOUNTINFO");
hm.clear();
session.removeAttribute("PORTFOLIO.RESPONSE");
String availBalance = FormatUtils.formatFloatToString(acInfo.getAccountBalance());
// Get the lines per page
int linesPerPage = acInfo.getLinesPerPage().intValue();
if (recordNum == null) recordNum = "1";
%>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bgcolor="#FFFFEA" bordercolor="#008000" height="80%">
<tr>
<td width="20%" bordercolor="#FFFFEA" valign="center" bgcolor="#FFFFD5">
<jsp:include page="LeftList.jsp" flush="TRUE"/>
</td>
<td bordercolor="#FFFFEA" valign="top" align="center">
<br>
<b><font face="Verdana, Times New Roman, Times, serif" color="#990000" size="2">
Portfolio Information
</font></b>
<br><br>
<table width="90%" cellpadding="2" cellspacing="2">
<%
// Set the iterator for the Collection
Iterator pvIter = pfCollection.iterator();
int rowCount = 0; // initialize row counter
String color1 = "#FFFFCC";
String color2 = "#CCFFCC";
String color = color2;
// Iterate through both the collections parallely
// since they contain values for the same row
while (pvIter.hasNext()) {
PortfolioValue pfv = (PortfolioValue)pvIter.next();
// Alternate between color1 and color2
color = (color.equals(color2))?color1:color2;
rowCount += 1;
// Display the Table header only once when the row count is 1
if (rowCount == 1) {
%>
<tr>
<th bgcolor="#008000" class="tabHead">
<div align="center">DATE</div>
</th>
<th bgcolor="#008000" class="tabHead">
<div align="center">NAME</div>
</th>
<th bgcolor="#008000" class="tabHead">
<div align="center">PRICE ($)</div>
</th>
<th bgcolor="#008000" class="tabHead">
<div align="center">CURRENT<br>PRICE ($)</div>
</th>
<th bgcolor="#008000" class="tabHead">
<div align="center">QUANTITY</div>
</th>
<th bgcolor="#008000" class="tabHead">
<div align="center">GAIN/<br>LOSS ($)</div>
</th>
<th bgcolor="#008000" class="tabHead">
<div align="center">GAIN (%)</div>
</th>
<th bgcolor="#008000" class="tabHead">
<div align="center">CURRENT<br>VALUE ($)</div>
</th>
</tr>
<%
}
// Display the values in the Collection
%>
<tr bgcolor="<%=color%>">
<td class="tableText" height="30">
<div align="center">
<%= DateFormatter.getStringFromDate(pfv.getPurchaseDate(), "dd-MMM-yyyy") %>
</div>
</td>
<td class="tableText" height="30">
<div align="left"><%=pfv.getCompanyName()%></div>
</td>
<td class="tableText" height="30">
<div align="right"><%=pfv.getPrice()%></div>
</td>
<td class="tableText" height="30">
<div align="right"><%=pfv.getCurrPrice()%></div>
</td>
<td class="tableText" height="30">
<div align="right"><%=pfv.getQuantity()%></div>
</td>
<td class="tableText" height="30">
<% String lossOrGain = FormatUtils.formatFloatToString(pfv.getGainorloss()); %>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="tableText" align="right"><%=lossOrGain%> </td>
<% if (lossOrGain.indexOf("-") == 0) { // Indicates Loss %>
<td width="20%"><img src="images/loss.gif" alt="Loss"> </td>
<% } else { %>
<td width="20%"> </td>
<% } %>
</tr>
</table>
</td>
<td class="tableText" height="30">
<div align="right"><%=FormatUtils.formatFloatToString(pfv.getPercent())%></div>
</td>
<td class="tableText" height="30">
<div align="right"><%=FormatUtils.formatFloatToString(pfv.getCurrValue())%></div>
</td>
</tr>
<% } %>
<%
// If the page required iteration, set a form with the RECORDNUM to the index of the
// first record and the EVENTNAME, display the Prev and Next buttons if required
if (hasPrev.equals("true") || hasNext.equals("true")) {
%>
<form name="PAGEFORMAT" action="controllerservlet" method="post">
<input type="hidden" name="EVENTNAME" value="PORTFOLIO">
<input type="hidden" name="RECORDNUM">
<tr bgcolor="#FFFFEA">
<td align="center">
<%
// If there are some more previous records, display the prev button
if (hasPrev.equals("true")) {
int prev = Integer.parseInt(recordNum) - linesPerPage;
%>
<img src="images/prev.gif" alt="Previous" onMouseUp="setRecordNum('<%=prev%>');">
<%
}
%>
</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td align="center">
<%
// If there are some more next records, display the next button
if (hasNext.equals("true")) {
int next = Integer.parseInt(recordNum) + linesPerPage;
%>
<img src="images/next.gif" alt="Next" onMouseUp="setRecordNum('<%=next%>');">
<%
}
%>
</td>
</tr>
</form>
<%
}
%>
</table>
<br>
<table width="80%" cellpadding="0" cellspacing="0">
<tr align="right">
<td>
<font face="Verdana, Times New Roman, Times, serif" color="#008000" size="2">
<b>Total Asset Value : </b>
</font>
</td>
<td width="20%">
<font face="Verdana, Times New Roman, Times, serif" color="#008000" size="2">
<b><u>$<%=totalAssetValue%></u></b>
</font>
</td>
</tr>
<tr align="right">
<td>
<font face="Verdana, Times New Roman, Times, serif" color="#008000" size="2">
<b>Account Balance : </b>
</font>
</td>
<td width="20%">
<font face="Verdana, Times New Roman, Times, serif" color="#008000" size="2">
<b><u>$<%=availBalance%></u></b>
</font>
</td>
</tr>
</table>
<%
// If the row counter is 0, it indicates that no Portfolio details exist for the user
// Hence display the corresponding message to the user
if (rowCount == 0) {
%>
<br><br>
<font face="Verdana, Times New Roman, Times, serif" color="#008000" size="2">
<b>No Transactions found for the logged in user...</b>
</font>
<%
}
%>
</td>
</tr>
</table>
<%
}
%>
<jsp:include page="Footer.jsp" flush="false"/>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -