/*
 * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
 * @author <a href="mailto:oliver.wehrens@aei.mpg.de">Oliver Wehrens</a>
 * @version $Id: PasswordTag.java 4666 2006-03-27 17:47:56Z novotny $
 */

package org.gridsphere.provider.portletui.tags;

import org.gridsphere.provider.portletui.beans.PasswordBean;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

/**
 * A <code>PasswordTag</code> provides a password tag for represnting HTML password input elements
 */
public class PasswordTag extends BaseComponentTag {

    protected PasswordBean passwordBean = null;

    protected int size = 10;
    protected int maxlength = 15;

    /**
     * Returns the (html) size of the field
     *
     * @return size of the field
     */
    public int getSize() {
        return size;
    }

    /**
     * Sets the (html) size of the field
     *
     * @param size size of the field
     */
    public void setSize(int size) {
        this.size = size;
    }

    /**
     * Returns the (html) max length of the field
     *
     * @return the max length of the field
     */
    public int getMaxlength() {
        return maxlength;
    }

    /**
     * Sets the (html) max length of the field
     *
     * @param maxlength the max length of the field
     */
    public void setMaxlength(int maxlength) {
        this.maxlength = maxlength;
    }

    public int doStartTag() throws JspException {

        if (!beanId.equals("")) {
            passwordBean = (PasswordBean) getTagBean();
            if (passwordBean == null) {
                passwordBean = new PasswordBean();
                this.setBaseComponentBean(passwordBean);
            } else {
                this.updateBaseComponentBean(passwordBean);
            }
        } else {
            passwordBean = new PasswordBean();
            passwordBean.setMaxLength(maxlength);
            passwordBean.setSize(size);
            this.setBaseComponentBean(passwordBean);
        }

        try {
            JspWriter out = pageContext.getOut();
            out.print(passwordBean.toStartString());
        } catch (Exception e) {
            throw new JspException(e.getMessage());
        }
        return SKIP_BODY;
    }

}

@@ -540,28 +540,20 @@
 extends 
-BaseComponen
+Inpu
 tTag %7B%0A%0A
@@ -1432,16 +1432,104 @@
 ption %7B%0A
+        return EVAL_BODY_INCLUDE;%0A    %7D%0A%0A    public int doEndTag() throws JspException %7B
 %0A       
@@ -2068,24 +2068,591 @@
 %0A        %7D%0A%0A
+        if (maxlength != 0) passwordBean.setMaxLength(maxlength);%0A        if (size != 0) passwordBean.setSize(size);%0A        if (onFocus != null) passwordBean.setOnFocus(onFocus);%0A        if (onClick != null) passwordBean.setOnClick(onClick);%0A        if (onChange != null) passwordBean.setOnChange(onChange);%0A        if (onBlur != null) passwordBean.setOnBlur(onBlur);%0A        if (onSelect != null) passwordBean.setOnSelect(onBlur);%0A%0A        if (cssClass != null) passwordBean.addCssClass(cssClass);%0A        if (cssStyle != null) passwordBean.addCssStyle(cssStyle);%0A%0A
         try 

fix up passwordtag to support size