<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<html:html locale="true">
  <head>
    <html:base />
	
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

	<title>Medien Application</title>
	</head>
	<body>
	<table border="0" width="100%" height="100%">
		<colgroup>
    		<col width="10%">
			<col width="80%">
			<col width="10%">
		</colgroup>
  		<!-- Kopfbereich -->
		<tr bgcolor="lightgrey" height="10%">
			<td align="center" colspan="3"><b>Show CD list</b></td>
		</tr>
		<!-- Hauptbereich -->
		<tr>
			<!-- Linker Navigationsbereich -->
			<td bgcolor="orange" valign="top" width="100">
				<% out.println(com.peetz.medien.navigation.MenuLinks.getInstance().toString()); %>
			</td>
			<td bgcolor="lightyellow" valign="top">
<table border="1">
 <tbody>
 <%-- set the header --%>
 <tr>
 <td>Category</td>
 <td>Album title</td>
 <td>Artist</td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 </tr>
 <%-- check if book exists and display message or iterate over cds  --%>
 <logic:empty name="cdListForm" property="cdViews">
 <tr>
 <td colspan="5">No CDs available</td>
 </tr>
 </logic:empty>
 <logic:notEmpty name="cdListForm" property="cdViews">
 <logic:iterate name="cdListForm" property="cdViews" id="cd">
 <tr>
 <%-- print out the book informations --%>
 <td><bean:write name="cd" property="category" /></td>
 <td><bean:write name="cd" property="album" /></td>
 <td><bean:write name="cd" property="artist" /></td>
 <%-- print out the edit and delete link for each CD --%>
 <td><html:link action="cdEdit.do?do=editCD" paramName="cd"
 paramProperty="id" paramId="id">Edit</html:link></td>
 <td><html:link action="cdEdit.do?do=deleteCD" paramName="cd"
 paramProperty="id" paramId="id">Delete</html:link></td>
 </tr>
 </logic:iterate>
 </logic:notEmpty>
 <%-- end interate --%>
	
 <%-- if cds cannot be found display a text --%>
 <logic:notPresent name="cd">
 <tr>
 <td colspan="5">No CDs found.</td>
 </tr>
 </logic:notPresent> 
	
 </tbody>
 </table>
  <br>
 <%-- add and back to menu button --%>
 <html:button property="add" onclick="location.href='../cdEdit.do?do=addCD'">Add a new CD
 </html:button>
 &nbsp;
 <html:button property="back" onclick="location.href='default.do'">Back to menu
 </html:button>
 
			</td>
			<!-- Rechter Navigationsbereich -->
			<td bgcolor="orange" with="15%">&nbsp;</td>
		</tr>
		<!-- Fussbereich -->
		<tr bgcolor="lightgrey" height="10%">
			<td align="right" colspan="3">
				<p>Ingenieurb&uuml;ro Thomas Peetz</p>
			</td>
		</tr>
	</table>
	</body>
</html:html>
