update.jsp
01 <%page contentType="text/html; charset=Shift_JIS" %>
02 <%page import="javax.naming.*,
03                  java.text.*,
04                  java.util.*,
05                  trail.entity.beans.*, trail.entity.update.*"%>
06 
07 <%!
08   private Calculator cal = null;
09   private NumberFormat nf = null;
10 
11   public void jspInit () {
12     try {
13       InitialContext ctx = new InitialContext();
14       cal = (Calculatorctx.lookup(
15                   "EJB3Trail/UpdateCalculator/local");
16     catch (Exception e) {
17       e.printStackTrace ();
18     }
19 
20     nf = NumberFormat.getInstance();
21     nf.setMaximumFractionDigits(2);
22   }
23 %>
24 
25 <%
26     if ("Update".equals(request.getParameter("action"))) {
27         cal.updateExchangeRate(
28             Double.parseDouble(
29                 request.getParameter("newrate")));
30     }
31 %>
32 
33 <html><body>
34 
35 <p>新しい為替で計算記録を更新する<br/>
36 <form action="update.jsp" method="POST">
37   変換レート = <input type="text" name="newrate" value="1.5">
38   <input type="hidden" name="action" value="Update"><br/>
39   <input type="submit" value="Update">
40   <INPUT type="button" value="Close Window" onClick="window.close()">
41 </form><br/>
42 
43 過去の計算記録<br/>
44 <table>
45 <tr>
46 <td>タイムスタンプ</td>
47 <td>投資会社</td>
48 <td>個人投資家</td>
49 <td>月掛金額</td>
50 <td><b>合計投資額</b></td>
51 </tr>
52 
53 <%
54     Collection records = cal.getRecords ();
55     for (Iterator iter = records.iterator(); iter.hasNext();) {
56         TimedRecord record = (TimedRecorditer.next();
57 %>
58 
59 <tr>
60 <td><%=record.getTs()%></td>
61 <td><%=record.getFund().getName()%></td>
62 <td><%=record.getInvestor().getName()%></td>
63 <td><%=nf.format(record.getSaving())%></td>
64 <td><%=nf.format(record.getResult())%></td>
65 </tr>
66 
67 <%
68     }
69 %>
70 </table>
71 
72 </p>
73 </body></html>