📄 sellstock.jsp
字号:
<?xml version = "1.0" encoding = "UTF-8" standalone="yes" ?>
<%--
* @author Elangovan
* @version 1.0
*
* Development Environment : Oracle9i JDeveloper
*
* Name of the File : SellStock.jsp
*
* Creation/Modification History :
*
* Elangovan 26-Apr-2002 Created
*
* Overview of Application :
*
* This page displays the list of stocks that are present in the portfolio.
* User can select any stock and enter the sell quantity to trade.
*
--%>
<%@page language="java" %>
<%@ page session="true" %>
<%@ page contentType="text/vnd.oracle.mobilexml; charset=UTF-8" %>
<%@page import="java.util.Collection" %>
<%@page import="java.util.Iterator" %>
<%@page import="java.util.HashMap" %>
<%@page import="oracle.otnsamples.ibfbs.usermanagement.ejb.AccountInfo" %>
<%@page import="oracle.otnsamples.ibfbs.trademanagement.ejb.PortfolioInfo" %>
<!DOCTYPE SimpleResult PUBLIC "-//ORACLE//DTD SimpleResult 1.1//EN"
"http://xmlns.oracle.com/ias/dtds/SimpleResult_1_1_0.dtd">
<SimpleResult>
<SimpleContainer>
<%
// Get eventname
String tab = request.getParameter("EVENTNAME");
if (tab.equals("MOBILE-SELL")) {
// Get the user portfolio
HashMap hm = (HashMap) session.getAttribute("MOBILE-SELL.RESPONSE");
Collection retCollection = (Collection)hm.get("PORTFOLIOINFO");
Iterator retIter = retCollection.iterator();
String hasPrev = "false";
String hasNext = "false";
Collection pfCollection = null;
if (retIter.hasNext()) {
hasPrev = (String)retIter.next();
hasNext = (String)retIter.next();
pfCollection = (Collection)retIter.next();
}
Iterator pfIter = null;
if(pfCollection != null)
pfIter = pfCollection.iterator();
// 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");
// Get the lines per page
int linesPerPage = acInfo.getLinesPerPage().intValue();
if (recordNum == null) recordNum = "1";
// If user had selected the stock to sell, TRADEID would have been set
String tradeid = request.getParameter("TRADEID");
// If TRADEID hasn't been set , display user portfolio
if(tradeid == null) {
// Empty portfolio
if (!pfIter.hasNext()) {
%>
<SimpleText>
<SimpleTextItem>No Transactions.</SimpleTextItem>
</SimpleText>
<SimpleMenu>
<SimpleMenuItem target="controllerservlet?EVENTNAME=MOBILE-PORTFOLIO">Continue</SimpleMenuItem>
</SimpleMenu>
<%
} else {
%>
<SimpleForm name="SELECTSYMBOL" method="POST" target="controllerservlet">
<SimpleFormItem name="EVENTNAME" type="text" displaymode="hidden" value="MOBILE-SELL"></SimpleFormItem>
<SimpleFormItem name="RECORDNUM" type="text" displaymode="hidden" value="<%=recordNum%>"></SimpleFormItem>
<SimpleFormSelect name="TRADEID" displaymode="checkbox" multiple="false" >
<%
do {
// Get Portfolio info
PortfolioInfo pif = (PortfolioInfo)pfIter.next();
%>
<SimpleFormOption value="<%=pif.getTradeId()%>" ><%=pif.getSymbol()%> bought on <%=pif.getPurchaseDate()%>@<%=pif.getPrice()%></SimpleFormOption>
<%
} while (pfIter.hasNext());
%>
</SimpleFormSelect>
</SimpleForm>
<% } %>
<SimpleMenu>
<SimpleTitle>Go to</SimpleTitle>
<%
// 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")) {
// If there are some more previous records, display the prev button
if (hasPrev.equals("true")) {
int prev = Integer.parseInt(recordNum) - linesPerPage;
%>
<SimpleMenuItem target="controllerservlet?EVENTNAME=MOBILE-SELL&RECORDNUM=<%=prev%>">Prev</SimpleMenuItem>
<%
}
// If there are some more next records, display the next button
if (hasNext.equals("true")) {
int next = Integer.parseInt(recordNum) + linesPerPage;
%>
<SimpleMenuItem target="controllerservlet?EVENTNAME=MOBILE-SELL&RECORDNUM=<%=next%>">Next</SimpleMenuItem>
<%
}
}
%>
<SimpleMenuItem target="controllerservlet?EVENTNAME=MOBILE-MYHOME">Home</SimpleMenuItem>
<SimpleMenuItem target="controllerservlet?EVENTNAME=MOBILE-BUY">Buy</SimpleMenuItem>
<SimpleMenuItem target="controllerservlet?EVENTNAME=MOBILE-TRANS">View Trans</SimpleMenuItem>
</SimpleMenu>
<%
} else {
PortfolioInfo pif = null;
// Iterate through the portfolio and get the selected record that has to
// be sold
while(pfIter.hasNext()) {
pif = (PortfolioInfo)pfIter.next();
if(pif.getTradeId().equals(tradeid))
break;
}
// Display record info
%>
<SimpleText>
<SimpleTextItem>Sell '<%=pif.getSymbol()%>' stock</SimpleTextItem>
</SimpleText>
<SimpleForm name="SELL" method="POST" target="controllerservlet">
<SimpleFormItem name="EVENTNAME" type="text" displaymode="hidden" value="MOBILE-SELLSTOCK"></SimpleFormItem>
<SimpleFormItem name="SELLQTY" type="text" displaymode="number" maxlength="6" mandatory="yes" >Sell Qty</SimpleFormItem>
<SimpleFormItem name="SYMBOL" type="text" displaymode="hidden" value="<%=pif.getSymbol()%>"></SimpleFormItem>
<SimpleFormItem name="LINENO" type="text" displaymode="hidden" value="<%=pif.getLineNo()%>"></SimpleFormItem>
<SimpleFormItem name="TRADEID" type="text" displaymode="hidden" value="<%=pif.getTradeId()%>"></SimpleFormItem>
</SimpleForm>
<%
}
} else if (tab.equals("MOBILE-SELLSTOCK")) {
String retMessage = (String) session.getAttribute("MOBILE-SELLSTOCK.RESPONSE");
%>
<SimpleText>
<SimpleTextItem><%=retMessage%></SimpleTextItem>
</SimpleText>
<SimpleMenu>
<SimpleMenuItem target="controllerservlet?EVENTNAME=MOBILE-PORTFOLIO">Continue</SimpleMenuItem>
</SimpleMenu>
<%
}
%>
</SimpleContainer>
</SimpleResult>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -