1 19 20 package com.sslexplorer.security.forms; 21 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 import javax.servlet.http.HttpServletRequest ; 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 personalAnswers; 42 43 public void initialize(List personalAnswers) { 44 this.personalAnswers = personalAnswers; 45 } 46 47 public List getPersonalAnswers() { 48 return personalAnswers; 49 } 50 51 public void setPersonalAnswers(List 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 request) { 64 ActionErrors err = new ActionErrors(); 65 for(Iterator 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 |