diff --git a/zul/src/org/zkoss/zul/Textbox.java b/zul/src/org/zkoss/zul/Textbox.java index ab5ebb4..1570d92 100644 --- a/zul/src/org/zkoss/zul/Textbox.java +++ b/zul/src/org/zkoss/zul/Textbox.java @@ -29,6 +29,12 @@ * @author tomyeh */ public class Textbox extends InputElement { + public static final String TEXT = "text"; + public static final String PASSWORD = "password"; + public static final String TEL = "tel"; + public static final String EMAIL = "email"; + public static final String URL = "url"; + private AuxInfo _auxinf; public Textbox() { @@ -80,11 +86,15 @@ /** Sets the type. * @param type the type. Acceptable values are "text" and "password". * Unlike XUL, "timed" is redundant because it is enabled as long as - * onChanging is added. Since 6.5.0 type also support tel, email and url. + * onChanging is added. Since 6.5.0 type also support "tel", "email" and "url". + *

+ * If you set the type from a richlet, you can use {@link Textbox#TEXT}, + * {@link Textbox#PASSWORD}, {@link Textbox#TEL}, {@link Textbox#EMAIL} + * or {@link Textbox#URL} constants instead of hard-coded strings. */ public void setType(String type) throws WrongValueException { - if (!TEXT.equals(type) && !"password".equals(type) && - !"tel".equals(type) && !"email".equals(type) && !"url".equals(type)) + if (!TEXT.equals(type) && !PASSWORD.equals(type) && + !TEL.equals(type) && !EMAIL.equals(type) && !URL.equals(type)) throw new WrongValueException("Illegal type: "+type); if (!type.equals(_auxinf != null ? _auxinf.type: TEXT)) { @@ -173,7 +183,6 @@ return _zclass != null ? _zclass: "z-textbox"; } - private static final String TEXT = "text"; private AuxInfo initAuxInfo() { if (_auxinf == null) _auxinf = new AuxInfo();