<%@ page contentType="text/html; charset=Shift_JIS" %>
<%@ page import="javax.naming.*,
                 java.text.*,
                 java.util.*,
                 trail.entity.beans.*, trail.apptrans.*"%>

<%!
  private NumberFormat nf = null;

  public void jspInit () {
    nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(2);
  }
%>

<%
  Calculator cal =
      (Calculator) session.getAttribute("apptrans_cal");
  if (cal == null) {
    try {
      InitialContext ctx = new InitialContext();
      cal = (Calculator) ctx.lookup(
                  "EJB3Trail/ApptransCalculator/local");
      session.setAttribute ("apptrans_cal", cal);
    } catch (Exception e) {
      e.printStackTrace ();
    }
  }

  if ("Update".equals(request.getParameter("action"))) {
    if ("yes".equals(request.getParameter("ts"))) {
      cal.updateTimestamp();
    }
    // Commit the changes by removing the bean
    cal.checkout ();
    session.setAttribute ("apptrans_cal", null);
%>

<html>
<body>
<center>
  <!--p><b>The changes have been persisted to the database</b></p-->
  <p><b>変更はデータベースへ永続化されました</b></p>
  <!--p><a href="update.jsp">Go back to the update screen</a></p-->
  <p><a href="update.jsp">更新画面に戻る</a></p>
</center>
</body>
</html>

<%
  } else {
%>

<html><body>

<!--p>Do you want to update the timestamps as well?<br/-->
<p>タイムスタンプも更新しますか?<br/>
<form action="update2.jsp" method="POST">
<input type="hidden" name="action" value="Update"/>
<input type="radio" name="ts" value="yes" checked>はい</input>
<input type="radio" name="ts" value="no">いいえ</input>
<br/>
<input type="submit" value="更新"/>
<INPUT type="button" value="閉じる" onClick="window.close()"/>
</form>
</p>
</body></html>

<%
  }
%>