1 18 19 package org.objectweb.jac.aspects.gui.web; 20 21 import java.io.PrintWriter ; 22 import org.objectweb.jac.aspects.gui.Length; 23 import org.objectweb.jac.core.rtti.FieldItem; 24 import org.objectweb.jac.core.rtti.NamingConventions; 25 import org.objectweb.jac.util.Strings; 26 27 28 32 public class PasswordFieldEditor extends AbstractFieldEditor 33 implements HTMLEditor 34 { 35 36 public PasswordFieldEditor(Object substance, FieldItem field) { 37 super(substance,field); 38 width = new Length("15ex"); 39 } 40 41 43 public void genHTML(PrintWriter out) { 44 out.println("<INPUT type=\"password\" class=\"editor\""+ 45 " name=\""+label+"\""+sizeSpec()); 46 printAttributes(out); 47 out.println(">"); 48 out.println("<BR>"); 49 out.print("<div class=\"label\">Retype " + 50 NamingConventions.textForName(field.getName()) + 51 ": </div>"); 52 out.println("<INPUT type=\"password\" class=\"editor\""+ 53 " name=\""+label+"Confirm"+"\""); 54 printAttributes(out); 55 out.println(">"); 56 } 57 58 protected boolean doReadValue(Object parameter) 59 throws RuntimeException 60 { 61 String string = (String )parameter; 62 63 if (!((String ) (WebDisplay.getRequest() 64 .getParameter(label+"Confirm"))).equals(string)) { 65 throw new RuntimeException ("'" + 66 NamingConventions.textForName(field.getName()) + 67 "'" + 68 " and its confirmation are different"); 69 } else { 70 if (Strings.isEmpty(string)) { 71 return false; 72 } 73 setValue(string); 74 } 75 return true; 76 } 77 } 78 79 | Popular Tags |