menu.jsp
<%@ page import="persistenceexample1.PersistenceExample" %>
<html>
<head>
<link rel="stylesheet" href="css/mi.css" type="text/css">
<!-- href uses "standard" ME settings: 127.0.0.1 = localhost on the Desktop and also works on the PDA -->
<a href="http://127.0.0.1:4444/me" > <img src="mimes/SAP_me.gif" alt="Back to ME Home" ></a>
</head>
<body>
<jsp:useBean id="dataBean" scope="session" class="persistenceexample1.bean.TableViewBean" />
<!-- For event handling we need a HTML "form" command -->
<form method="post" action="start" id="form1" name="form2">
<!-- Display title of the example -->
<h6><%=dataBean.getString() %></h6>
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align="center" width="25%" class="commandLine">
<!-- Add button to add an entry -->
<input type="submit" value="Add" class="image" name="_event_addEntry">
</td>
<td align="center" width="25%" class="commandLine">
<!-- Delete button to delete entries that are marked by the checkbox -->
<input type="submit" class="image" name="_event_delEntry" value="Delete" >
</td>
<td align="center" width="25%" class="commandLine">
<!-- List all entries in Persistence layer button -->
<input type="submit" class="image" name="_event_listEntries" value="<%=dataBean.getButton()%>" >
</td>
<td align="center" width="25%" class="commandLine">
<!-- Save data in database (commit) -->
<input type="submit" class="image" name="_event_saveEntries" value="Save" >
</td>
</tr>
</table>
<!-- Table definition -->
<table width="100%" bgcolor="#D4E2EE" border="0" cellspacing="0" cellpadding="0" >
<%
int cols = dataBean.getTableColumns();
int rows = dataBean.getTableRows();
// Background color for title row
String bgColor = "#9CAECE";
String rowClass = "miHeader";
for(int i=0; i < rows; i++) {
String cellClass = "1stCellHeader";
if (i > 0) cellClass = "1stCellBody";
// begin of a row
%> <tr bgcolor="<%=bgColor %>" class="<%=rowClass%>" > <%
for(int j=0; j < cols; j++) {
// In the first column (except the title row) we display a checkbox, that can be used to mark an entry
/// that should be deleted. The checkbox gets the name which is supplied by the dataBean. This name is
/// used in the servlet to determine which entry should be deleted
if ((j == 0) && (i > 0)) {
%> <td align="center" valign="middle" class="<%=cellClass%>" > <INPUT TYPE="CHECKBOX" Name="<%=dataBean.getTableContent(i, j)%>" Value="<%=dataBean.getTableContent(i, j)%>"</td> <%
} else {
// Column 2 and higher displays the Car entity and License entity. We display the entry in HTML encoded.
/// If the string is empty we display a non breaking space so that the table gets the separation lines.
/// The encoding is not done for the title
String value = dataBean.getTableContent(i, j);
if (i > 1) {
value = PersistenceExample.encodeForHtml(value);
}
if (value.trim().length() < 1){
value = " ";
}
%> <td align="left" valign="middle" class="<%=cellClass%>" > <%=value%> </td> <%
}
cellClass = "nextCellHeader";
if (i > 0) cellClass = "nextCellBody";
}
rowClass = "miBody";
// end of a row
%> </tr> <%
// To make the tableview look nicer, we use alternating colors for rows (light blue and light grey)
if (bgColor.compareTo("#DCE3EC") == 0) {
// light blue
bgColor = "#CBD5E1";
} else {
// lighter blue
bgColor = "#DCE3EC";
}
}
%>
</table>
</form>
</body>
</html>