1
16package org.tp23.antinstaller.input;
17
18import org.tp23.antinstaller.InstallerContext;
19import org.tp23.antinstaller.ValidationException;
20
21
26public class ConfirmPasswordTextInput
27 extends PasswordTextInput
28{
29 private String origField;
30
31
36 public boolean validate(InstallerContext ctx) throws ValidationException{
37 OutputField[] otherFields = ctx.getCurrentPage().getOutputField();
38 for (int i = 0; i < otherFields.length; i++) {
39 if(otherFields[i] instanceof PasswordTextInput &&
40 otherFields[i] != this){
41 PasswordTextInput pwd = (PasswordTextInput)otherFields[i];
42 if(pwd.getProperty().equals(getOrigField())){
43 return this.getInputResult().equals(pwd.getInputResult());
44 }
45 }
46 }
47 throw new ValidationException("Confirm password requires a PasswordTextInput, on the same page, with property " + getOrigField());
48 }
49
50 public boolean validateObject() {
51 if ( ! super.validateObject()){
52 return false;
53 }
54 if(getOrigField() == null){
55 System.out.println("ConfirmPassword:origField must be set");
56 return false;
57 }
58 return true;
60 }
61
62 public String getOrigField() {
63 return origField;
64 }
65
66 public void setOrigField(String origField) {
67 this.origField = origField;
68 }
69
70}
71