001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: /*
017: * Created on Sep 3, 2004
018: *
019: */
020: package org.kuali.module.pdp.form.bank;
021:
022: import java.util.Enumeration;
023:
024: import javax.servlet.http.HttpServletRequest;
025:
026: import org.apache.struts.action.ActionErrors;
027: import org.apache.struts.action.ActionForm;
028: import org.apache.struts.action.ActionMapping;
029: import org.apache.struts.action.ActionMessage;
030: import org.kuali.module.pdp.bo.Bank;
031:
032: /**
033: * @author jsissom
034: */
035: public class BankForm extends ActionForm {
036: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
037: .getLogger(BankForm.class);
038:
039: private Integer id;
040: private Integer version;
041: private String description;
042: private String name;
043: private String routingNumber;
044: private String accountNumber;
045: private Boolean active;
046: private String disbursementTypeCode;
047:
048: public BankForm() {
049: super ();
050: }
051:
052: public BankForm(Bank b) {
053: super ();
054: id = b.getId();
055: version = b.getVersion();
056: description = b.getDescription();
057: name = b.getName();
058: routingNumber = b.getRoutingNumber();
059: accountNumber = b.getAccountNumber();
060: active = b.getActive();
061: if (b.getDisbursementType() != null) {
062: disbursementTypeCode = b.getDisbursementType().getCode();
063: }
064: }
065:
066: public ActionErrors validate(ActionMapping mapping,
067: HttpServletRequest request) {
068: ActionErrors ae = new ActionErrors();
069:
070: String b = "none";
071: Enumeration e = request.getParameterNames();
072: while (e.hasMoreElements()) {
073: String name = (String) e.nextElement();
074: if (name.startsWith("btn")) {
075: b = name;
076: break;
077: }
078: }
079:
080: if (b.startsWith("btnSave")) {
081: if ((description == null) || (description.length() == 0)) {
082: ae.add("description", new ActionMessage(
083: "bankform.missing.description"));
084: }
085: if ((name == null) || (name.length() == 0)) {
086: ae.add("name", new ActionMessage(
087: "bankform.missing.name"));
088: }
089: if ((accountNumber == null)
090: || (accountNumber.length() == 0)) {
091: ae.add("accountNumber", new ActionMessage(
092: "bankform.missing.accountNumber"));
093: }
094: if ((routingNumber == null)
095: || (routingNumber.length() == 0)) {
096: ae.add("routingNumber", new ActionMessage(
097: "bankform.missing.routingNumber"));
098: }
099: }
100:
101: return ae;
102: }
103:
104: public String getAccountNumber() {
105: return accountNumber;
106: }
107:
108: public void setAccountNumber(String accountNumber) {
109: this .accountNumber = accountNumber;
110: }
111:
112: public Boolean getActive() {
113: return active;
114: }
115:
116: public void setActive(Boolean active) {
117: this .active = active;
118: }
119:
120: public String getDescription() {
121: return description;
122: }
123:
124: public void setDescription(String description) {
125: this .description = description;
126: }
127:
128: public String getDisbursementTypeCode() {
129: return disbursementTypeCode;
130: }
131:
132: public void setDisbursementTypeCode(String disbursementTypeCode) {
133: this .disbursementTypeCode = disbursementTypeCode;
134: }
135:
136: public Integer getId() {
137: return id;
138: }
139:
140: public void setId(Integer id) {
141: this .id = id;
142: }
143:
144: public String getName() {
145: return name;
146: }
147:
148: public void setName(String name) {
149: this .name = name;
150: }
151:
152: public String getRoutingNumber() {
153: return routingNumber;
154: }
155:
156: public void setRoutingNumber(String routingNumber) {
157: this .routingNumber = routingNumber;
158: }
159:
160: public Integer getVersion() {
161: return version;
162: }
163:
164: public void setVersion(Integer version) {
165: this.version = version;
166: }
167: }
|