<%-- Specify the use of the EJB taglib --%>
<%@ page import="java.text.*" %>
<%@ taglib uri="ejbtags" prefix="ejb" %>

<% DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, request.getLocale()); %>

<html>
	<head>
		<title>News</title>
	</head>
	<body bgcolor="e0d0c0">
		<font size="5" face="Arial"><b>Useless news HQ search results</b></font><br>

		<%-- Look up the home --%>
		<ejb:useHome id="home" type="com.evermind.ejb.NewsItemHome" location="java:comp/env/ejb/NewsItem" />

		<table border="2">
			<tr><td bgcolor="7070a0"><b>Date</b></td><td bgcolor="7070a0"><b>Subject</b></td></tr>
			
			<%-- Iterate thru the news items, max 20 of them --%>
			<ejb:iterate id="news" type="com.evermind.ejb.NewsItem" collection="<%=home.findByContent("%" + request.getParameter("content") + "%")%>" max="20">
				<tr>
					<td bgcolor="ffffff"><%=dateFormat.format(news.getDate())%></td>
					<td bgcolor="ffffff"><jsp:getProperty name="news" property="subject" /> (<a href="newsdetail.jsp?id=<%=news.getId()%>">detail</a>)</td>
				</tr>
			</ejb:iterate>
		</table>
	</body>
</html>