KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > applications > webtalk > controller > DropCustomerSelectForm


1 /*
2  * DropCustomerSelectForm.java
3  *
4  * Created on April 24, 2004, 1:02 PM
5  */

6
7 package com.quikj.application.communicator.applications.webtalk.controller;
8
9 import java.net.URLEncoder JavaDoc;
10 import java.sql.Connection JavaDoc;
11 import java.util.ArrayList JavaDoc;
12 import java.util.Iterator JavaDoc;
13
14 import javax.servlet.http.HttpServletRequest JavaDoc;
15
16 import org.apache.struts.action.ActionError;
17 import org.apache.struts.action.ActionErrors;
18 import org.apache.struts.action.ActionForm;
19 import org.apache.struts.action.ActionMapping;
20 import org.apache.struts.util.LabelValueBean;
21
22 import com.quikj.application.communicator.applications.webtalk.model.GroupTable;
23
24 /**
25  *
26  * @author bhm
27  */

28 public class DropCustomerSelectForm extends ActionForm
29 {
30
31     /** Holds value of property submit. */
32     private String JavaDoc submit;
33
34     /** Holds value of property domain. */
35     private String JavaDoc domain;
36
37     /** Holds value of property domains. */
38     private ArrayList JavaDoc domains = new ArrayList JavaDoc();
39
40     /** Creates a new instance of DropCustomerSelectForm */
41     public DropCustomerSelectForm()
42     {
43     }
44
45     public ActionErrors validate(ActionMapping mapping,
46             HttpServletRequest JavaDoc request)
47     {
48         if (submit.startsWith("Cancel") == true)
49         {
50             return null;
51         }
52
53         // Check for mandatory data
54
ActionErrors errors = new ActionErrors();
55
56         try
57         {
58             if ((domain == null) || (domain.length() == 0))
59             {
60                 errors.add("domains", new ActionError(
61                         "error.customer.select.domain"));
62             }
63
64             if (errors.isEmpty() == false)
65             {
66                 GroupTable groups = new GroupTable();
67                 Connection JavaDoc c = (Connection JavaDoc) request.getSession().getAttribute(
68                         "connection");
69                 groups.setConnection(c);
70
71                 ArrayList JavaDoc domain_list = groups.listDomains();
72
73                 if (domain_list != null)
74                 {
75                     ArrayList JavaDoc list = new ArrayList JavaDoc();
76                     Iterator JavaDoc iter = domain_list.iterator();
77
78                     while (iter.hasNext() == true)
79                     {
80                         String JavaDoc domain = (String JavaDoc) iter.next();
81
82                         if (domain.equals("ace") == false)
83                         {
84                             list.add(new LabelValueBean(domain, URLEncoder
85                                     .encode(domain, "UTF-8")));
86                         }
87                     }
88
89                     setDomains(list);
90                 }
91             }
92         }
93         catch (Exception JavaDoc e)
94         {
95             errors.add("domains", new ActionError("error.internal.error"));
96         }
97         return errors;
98     }
99
100     /**
101      * Getter for property submit.
102      *
103      * @return Value of property submit.
104      *
105      */

106     public String JavaDoc getSubmit()
107     {
108         return this.submit;
109     }
110
111     /**
112      * Setter for property submit.
113      *
114      * @param submit
115      * New value of property submit.
116      *
117      */

118     public void setSubmit(String JavaDoc submit)
119     {
120         this.submit = submit;
121     }
122
123     /**
124      * Getter for property domain.
125      *
126      * @return Value of property domain.
127      *
128      */

129     public String JavaDoc getDomain()
130     {
131         return this.domain;
132     }
133
134     /**
135      * Setter for property domain.
136      *
137      * @param domain
138      * New value of property domain.
139      *
140      */

141     public void setDomain(String JavaDoc domain)
142     {
143         this.domain = domain;
144     }
145
146     /**
147      * Getter for property domains.
148      *
149      * @return Value of property domains.
150      *
151      */

152     public ArrayList JavaDoc getDomains()
153     {
154         return this.domains;
155     }
156
157     /**
158      * Setter for property domains.
159      *
160      * @param domains
161      * New value of property domains.
162      *
163      */

164     public void setDomains(ArrayList JavaDoc domains)
165     {
166         this.domains = domains;
167     }
168
169 }
Popular Tags