01: package org.gridsphere.provider.portletui.tags;
02:
03: import org.gridsphere.provider.portletui.beans.ValidatorBean;
04:
05: import javax.servlet.jsp.JspException;
06: import javax.servlet.jsp.tagext.Tag;
07:
08: /**
09: * A <code>TextTag</code> represents text to be displayed
10: */
11: public class ValidatorTag extends BaseComponentTag {
12:
13: protected ValidatorBean validatorBean = null;
14: protected String type = "";
15:
16: /**
17: * Sets the validator type
18: *
19: * @param type the validator type
20: */
21: public void setType(String type) {
22: this .type = type;
23: }
24:
25: /**
26: * Returns the validator type
27: *
28: * @return the validator type
29: */
30: public String getType() {
31: return type;
32: }
33:
34: public int doStartTag() throws JspException {
35: Tag parent = this .getParent();
36: if (parent instanceof TextFieldTag) {
37: TextFieldTag textField = (TextFieldTag) parent;
38: if (key != null)
39: value = this .getLocalizedText(key);
40: String tfClass = type;
41: textField.addCssClass(tfClass + "#");
42: ValidatorBean validatorBean = new ValidatorBean();
43: validatorBean.setValue(value);
44: validatorBean.setType(type);
45: textField.addValidatorBean(validatorBean);
46: }
47: super.release();
48: return SKIP_BODY;
49: }
50:
51: }
|