01: package dinamica;
02:
03: /**
04: * Exception triggered when request generic
05: * validation fails
06: * <br>
07: * Creation date: 25/10/2003<br>
08: * Last Update: 25/10/2003<br>
09: * @author Martin Cordova
10: */
11: public class RequestValidationException extends Throwable {
12:
13: /**
14: *
15: */
16: private static final long serialVersionUID = 1L;
17:
18: Recordset rs = new Recordset();
19:
20: public RequestValidationException() {
21: /* create recordset to contain error messages for multiple parameters */
22: try {
23: rs.append("id", java.sql.Types.VARCHAR);
24: rs.append("message", java.sql.Types.VARCHAR);
25: } catch (RecordsetException e) {
26: }
27: }
28:
29: /**
30: * Stores an error message
31: * @param msg Error message
32: */
33: public void addMessage(String msg) {
34: rs.addNew();
35: try {
36: rs.setValue("message", msg);
37: } catch (RecordsetException e) {
38: }
39: }
40:
41: public void addMessage(String id, String msg) {
42: rs.addNew();
43: try {
44: rs.setValue("id", id);
45: rs.setValue("message", msg);
46: } catch (RecordsetException e) {
47: }
48: }
49:
50: /* (non-Javadoc)
51: * @see java.lang.Throwable#getMessage()
52: */
53: public String getMessage() {
54: return "Generic request validation failed.";
55: }
56:
57: /**
58: * Return recordset with list of errors. The recordset
59: * contains one column (message). May be printed using
60: * a regular Action and a template of you choice
61: * @return Recordset object containing error messages for each invalid parameter
62: */
63: public Recordset getErrors() {
64: return rs;
65: }
66:
67: }
|