package dk.hansen; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.*; public final class DetailVhsForm extends ActionForm { /* Id */ private String id = null; public String getId() { return (this.id); } public void setId(String id) { this.id = id; } /* Year */ private int year; public int getYear() { return (this.year); } public void setYear(int year) { this.year = year; } /* Title */ private String title = null; public String getTitle() { return (this.title); } public void setTitle(String title) { this.title = title; } /* TapeLength */ private int tapeLength; public int getTapeLength() { return (this.tapeLength); } public void setTapeLength(int tapeLength) { this.tapeLength = tapeLength; } public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // Log the forms data servlet.log("Id:" + id); servlet.log("Year:" + year); servlet.log("Title:" + title); servlet.log("TapeLength:" + tapeLength); // Check if properties are present ActionErrors errors = new ActionErrors(); if (id == null || id.equals("")) { errors.add("id", new ActionError("error.id.missing")); } // Should check for errors on year (type: int) if (title == null || title.equals("")) { errors.add("title", new ActionError("error.title.missing")); } // Should check for errors on tapeLength (type: int) return errors; } }