In this lab, you will modify the page infrastructure provided in the StringTemplate lecture to add another page and to develop another site skin.
First, compile and get the lecture code to work. That is,
Create another page called EMailListPage that displays email headers stored as fields of EMail objects.
public class EMail { public String from; public String to; public String subject; public String content; public EMail(String from, String to, String subject, String content) { this.from = from; this.to = to; this.subject = subject; this.content = content; } }
Like the UserListPage, create a simulated database in your EMailListPage:
/** Our simulated database */ static EMail[] users = new EMail[] { new EMail("parrt", "tombu", "parking issues", "no space!"); ... };
Modify the DispatchServlet so that it maps /mail/email to your new page.
Use only fields from, to, and subject. Put them as columns in a 3-column table. Each row will be a new email message:
<table> <tr> <td>From</td><td>To</td><td>Subject</td> </tr> <tr> <td>parrt</td><td>tombu</td><td>parking issues</td> </tr> ... </table>
You will need to create a new page template email_page.st in the templates subdirectory and have EMailListPage load an instance of it. The body() method will return a StringTemplate instance of email_page.st once it fills in the data.
To fill the body template with data, simply set an attribute perhaps called email with the simulated database of email.