| 1 6 7 package com.quikj.application.communicator.applications.webtalk.controller; 8 9 import java.net.URLEncoder ; 10 import java.sql.Connection ; 11 import java.util.ArrayList ; 12 import java.util.Iterator ; 13 14 import javax.servlet.http.HttpServletRequest ; 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 28 public class DropCustomerSelectForm extends ActionForm 29 { 30 31 32 private String submit; 33 34 35 private String domain; 36 37 38 private ArrayList domains = new ArrayList (); 39 40 41 public DropCustomerSelectForm() 42 { 43 } 44 45 public ActionErrors validate(ActionMapping mapping, 46 HttpServletRequest request) 47 { 48 if (submit.startsWith("Cancel") == true) 49 { 50 return null; 51 } 52 53 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 c = (Connection ) request.getSession().getAttribute( 68 "connection"); 69 groups.setConnection(c); 70 71 ArrayList domain_list = groups.listDomains(); 72 73 if (domain_list != null) 74 { 75 ArrayList list = new ArrayList (); 76 Iterator iter = domain_list.iterator(); 77 78 while (iter.hasNext() == true) 79 { 80 String domain = (String ) 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 e) 94 { 95 errors.add("domains", new ActionError("error.internal.error")); 96 } 97 return errors; 98 } 99 100 106 public String getSubmit() 107 { 108 return this.submit; 109 } 110 111 118 public void setSubmit(String submit) 119 { 120 this.submit = submit; 121 } 122 123 129 public String getDomain() 130 { 131 return this.domain; 132 } 133 134 141 public void setDomain(String domain) 142 { 143 this.domain = domain; 144 } 145 146 152 public ArrayList getDomains() 153 { 154 return this.domains; 155 } 156 157 164 public void setDomains(ArrayList domains) 165 { 166 this.domains = domains; 167 } 168 169 } | Popular Tags |