001: /*
002: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
003: * @author <a href="mailto:oliver.wehrens@aei.mpg.de">Oliver Wehrens</a>
004: * @version $Id: PasswordTag.java 6385 2007-10-25 14:02:26Z wehrens $
005: */
006:
007: package org.gridsphere.provider.portletui.tags;
008:
009: import org.gridsphere.provider.portletui.beans.PasswordBean;
010:
011: import javax.servlet.jsp.JspException;
012: import javax.servlet.jsp.JspWriter;
013:
014: /**
015: * A <code>PasswordTag</code> provides a password tag for represnting HTML password input elements
016: */
017: public class PasswordTag extends InputTag {
018:
019: protected PasswordBean passwordBean = null;
020:
021: protected int size = 10;
022: protected int maxlength = 15;
023:
024: /**
025: * Returns the (html) size of the field
026: *
027: * @return size of the field
028: */
029: public int getSize() {
030: return size;
031: }
032:
033: /**
034: * Sets the (html) size of the field
035: *
036: * @param size size of the field
037: */
038: public void setSize(int size) {
039: this .size = size;
040: }
041:
042: /**
043: * Returns the (html) max length of the field
044: *
045: * @return the max length of the field
046: */
047: public int getMaxlength() {
048: return maxlength;
049: }
050:
051: /**
052: * Sets the (html) max length of the field
053: *
054: * @param maxlength the max length of the field
055: */
056: public void setMaxlength(int maxlength) {
057: this .maxlength = maxlength;
058: }
059:
060: public int doStartTag() throws JspException {
061: return EVAL_BODY_INCLUDE;
062: }
063:
064: public int doEndTag() throws JspException {
065: if (!beanId.equals("")) {
066: passwordBean = (PasswordBean) getTagBean();
067: if (passwordBean == null) {
068: passwordBean = new PasswordBean();
069: this .setBaseComponentBean(passwordBean);
070: } else {
071: this .updateBaseComponentBean(passwordBean);
072: }
073: } else {
074: passwordBean = new PasswordBean();
075: passwordBean.setMaxLength(maxlength);
076: passwordBean.setSize(size);
077: this .setBaseComponentBean(passwordBean);
078: }
079:
080: if (maxlength != 0)
081: passwordBean.setMaxLength(maxlength);
082: if (size != 0)
083: passwordBean.setSize(size);
084: if (onFocus != null)
085: passwordBean.setOnFocus(onFocus);
086: if (onClick != null)
087: passwordBean.setOnClick(onClick);
088: if (onChange != null)
089: passwordBean.setOnChange(onChange);
090: if (onBlur != null)
091: passwordBean.setOnBlur(onBlur);
092: if (onSelect != null)
093: passwordBean.setOnSelect(onBlur);
094:
095: if (cssClass != null)
096: passwordBean.addCssClass(cssClass);
097: if (cssStyle != null)
098: passwordBean.addCssStyle(cssStyle);
099:
100: try {
101: JspWriter out = pageContext.getOut();
102: out.print(passwordBean.toStartString());
103: } catch (Exception e) {
104: throw new JspException(e.getMessage());
105: }
106: return SKIP_BODY;
107: }
108:
109: }
|