<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%
      java.util.List menu = (java.util.List)request.getSession().getAttribute("menu");
 %>

<html>
<head>
  <title>PDA-Application Beachclub Menu</title>
  <script type="text/javascript">
    function makeOrder(index)
    {
       document.forms[0].elements[0].value = index;
       document.forms[0].submit();
    }
   
    function cancel()
    {
       location.href = "Menu.jsp";
    }
  </script>
</head>
<body>
 <center>
  <h1>Beachclub Menu</h1>
  <h2>Make your Order</h2>
  <html:errors/></p>
  <table border="1">
    <tr><th><b>Name:</b></th><th><b>Price:</b></th><th><b>Order:</b></th></tr>
    <% 
          java.util.Iterator itor = menu.iterator();
          int i = 0;
          while (itor.hasNext())
          {
            com.ferienclub.beachclub.esb.messages.MenuItem mi = (com.ferienclub.beachclub.esb.messages.MenuItem)itor.next();
            java.lang.String name = mi.getName();
            double price = mi.getPrice();
            %> 
            <tr>
              <td><%= name %></td>
              <td><%= price %></td>
              <td><input type="button" value="Order" onclick="makeOrder(<%= i %>)"/></td>
            </tr>
           <%
	   i++;
          }
     %>
  </table>
  <input type="button" value="Cancel" onclick="cancel()"/>
 </center>

 <html:form action="makeOrder.do">
   <html:hidden name="orderForm" property="orderIndex"/>
 </html:form>

</body>
</html>
