View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.controller;
17  
18  import javax.servlet.http.HttpServletRequest;
19  
20  import org.apache.struts.action.ActionErrors;
21  import org.apache.struts.action.ActionMapping;
22  import org.apache.struts.action.ActionMessage;
23  import org.apache.struts.action.ActionMessages;
24  import org.apache.struts.validator.ValidatorForm;
25  
26  /***
27   * @author someda
28   */
29  public class UserForm extends ValidatorForm {
30  		
31  	private static final long serialVersionUID = -8743153463218216811L;
32  	
33  	private String name;
34  	private String password;
35  	private String passwordconfirm;
36  	private String[] roles;
37  	private String otherattributes;
38  	private String description;
39  	private boolean modify = false;
40  	
41  	public UserForm(){		
42  	}
43  	
44  	public String getDescription() {
45  		return description;
46  	}
47  	
48  	public void setDescription(String description) {
49  		this.description = description;
50  	}
51  	
52  	public String getName() {
53  		return name;
54  	}
55  	
56  	public void setName(String name) {
57  		this.name = name;
58  	}
59  	
60  	public String getOtherattributes() {
61  		return otherattributes;
62  	}
63  	
64  	public void setOtherattributes(String otherattributes) {
65  		this.otherattributes = otherattributes;
66  	}
67  	
68  	public String getPassword() {
69  		return password;
70  	}
71  	
72  	public void setPassword(String password) {
73  		this.password = password;
74  	}
75  	
76  	public String getPasswordconfirm() {
77  		return passwordconfirm;
78  	}
79  	
80  	public void setPasswordconfirm(String passwordconfirm) {
81  		this.passwordconfirm = passwordconfirm;
82  	}
83  	
84  	public String[] getRoles() {
85  		return roles;
86  	}
87  	
88  	public void setRoles(String[] roles) {
89  		this.roles = roles;
90  	}
91  
92  	public boolean isModify() {
93  		return modify;
94  	}
95  
96  	public void setModify(boolean modify) {
97  		this.modify = modify;
98  	}
99  	
100 	public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) {
101 
102 		if(!getPassword().equals(getPasswordconfirm())){
103 			ActionMessages msgs = new ActionMessages();
104 			msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("userform.confirm"));
105 			ActionErrors errors = new ActionErrors();
106 			errors.add(msgs);
107 			return errors;						
108 		}
109 		return super.validate(mapping, request);
110 	}	
111 }