KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dinamica > RequestValidationException


1 package dinamica;
2
3 /**
4  * Exception triggered when request generic
5  * validation fails
6  * <br>
7  * Creation date: 25/10/2003<br>
8  * Last Update: 25/10/2003<br>
9  * @author Martin Cordova
10  */

11 public class RequestValidationException extends Throwable JavaDoc
12 {
13
14     /**
15      *
16      */

17     private static final long serialVersionUID = 1L;
18     
19     Recordset rs = new Recordset();
20
21     public RequestValidationException()
22     {
23         /* create recordset to contain error messages for multiple parameters */
24         try
25         {
26             rs.append("message", java.sql.Types.VARCHAR);
27         }
28         catch (RecordsetException e){}
29     }
30     
31     /**
32      * Stores an error message
33      * @param msg Error message
34      */

35     public void addMessage(String JavaDoc msg)
36     {
37         rs.addNew();
38         try
39         {
40             rs.setValue("message", msg);
41         }
42         catch (RecordsetException e){}
43     }
44     
45     /* (non-Javadoc)
46      * @see java.lang.Throwable#getMessage()
47      */

48     public String JavaDoc getMessage()
49     {
50         return "Generic request validation failed.";
51     }
52
53     /**
54      * Return recordset with list of errors. The recordset
55      * contains one column (message). May be printed using
56      * a regular Action and a template of you choice
57      * @return Recordset object containing error messages for each invalid parameter
58      */

59     public Recordset getErrors()
60     {
61         return rs;
62     }
63
64 }
65
Popular Tags