01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets;
06:
07: import java.awt.*;
08: import java.util.*;
09:
10: import javax.servlet.*;
11:
12: import com.javelin.swinglets.event.*;
13:
14: /**
15: * FormEvent is fired when a Form changes in a Servlet.
16: *
17: * @author Robin Sharp
18: */
19:
20: public class ServletFormEvent extends FormEvent {
21: /**
22: * Construct a fully qualified ServletFormEvent
23: */
24: public ServletFormEvent(Object source, int id,
25: ServletRequest request) {
26: super (source, id);
27: this .request = request;
28: }
29:
30: /**
31: * Construct a fully qualified ServletFormEvent
32: */
33: public ServletFormEvent(Object source, String method,
34: ServletRequest request) {
35: super (source, method);
36: this .request = request;
37: }
38:
39: /**
40: * Get the parameter names.
41: */
42: public Enumeration getParameterNames() {
43: return request.getParameterNames();
44: }
45:
46: /**
47: * Get the parameter value.
48: */
49: public String getParameter(String name) {
50: return request.getParameter(name);
51: }
52:
53: /**
54: * Get the parameter values.
55: */
56: public String[] getParameterValues(String name) {
57: return request.getParameterValues(name);
58: }
59:
60: /**
61: * Get the action for the event.
62: */
63: public String getAction() {
64: if (action == null) {
65: action = request.getParameter("action");
66: }
67:
68: return action;
69: }
70:
71: /**
72: * Print out debug info.
73: */
74: public String toString() {
75: StringBuffer buf = new StringBuffer();
76: buf.append("ACTION=" + action + "\n");
77:
78: //for( Enumeration attributes = request.getAttributeNames(); attributes.hasMoreElements(); )
79: //{
80: // String name = attributes.nextElement().toString();
81: // System.out.println( "ATTRIBUTES NAME=" + name + ",VALUE=" + request.getAttribute( name ) );
82: //}
83:
84: for (Enumeration names = request.getParameterNames(); names
85: .hasMoreElements();) {
86: String name = names.nextElement().toString();
87: buf.append("PARAM NAME=" + name + ",VALUE="
88: + request.getParameter(name) + "\n");
89: }
90:
91: return buf.toString();
92: }
93:
94: // PRIVATE ////////////////////////////////////////////////////////
95:
96: private ServletRequest request;
97: private String action;
98:
99: }
|