KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > security > forms > PersonalAnswersForm


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.security.forms;
21
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.struts.Globals;
30 import org.apache.struts.action.ActionErrors;
31 import org.apache.struts.action.ActionMapping;
32 import org.apache.struts.action.ActionMessage;
33
34 import com.sslexplorer.core.forms.CoreForm;
35 import com.sslexplorer.security.PersonalAnswer;
36
37 public class PersonalAnswersForm extends CoreForm {
38
39     static Log log = LogFactory.getLog(PersonalAnswersForm.class);
40
41     private List JavaDoc personalAnswers;
42
43     public void initialize(List JavaDoc personalAnswers) {
44         this.personalAnswers = personalAnswers;
45     }
46     
47     public List JavaDoc getPersonalAnswers() {
48         return personalAnswers;
49     }
50     
51     public void setPersonalAnswers(List JavaDoc personalAnswers) {
52         this.personalAnswers = personalAnswers;
53     }
54     
55     public PersonalAnswer getPersonalAnswer(int idx) {
56       return (PersonalAnswer)personalAnswers.get(idx);
57     }
58     
59     public void setPersonalAnswer(int idx, PersonalAnswer personalAnswer) {
60         personalAnswers.set(idx, personalAnswer);
61     }
62
63     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
64         ActionErrors err = new ActionErrors();
65         for(Iterator JavaDoc i = personalAnswers.iterator(); i.hasNext(); ) {
66             PersonalAnswer answer = (PersonalAnswer)i.next();
67             if(answer.getAnswer().equals("")) {
68                 err.add(Globals.ERROR_KEY, new ActionMessage("setPersonalAnswers.error.emptyAnswer"));
69                 break;
70             }
71         }
72         return err;
73     }
74 }
75
Popular Tags