package cn.cerc.ui.vcl;

import cn.cerc.ui.core.HtmlWriter;
import cn.cerc.ui.core.INameOwner;
import cn.cerc.ui.parts.UIComponent;

public class UIInput extends UIComponent implements INameOwner {
    private String caption;
    private String name;
    private String value;
    private boolean readonly;
    private boolean hidden;
    private String placeholder;

    public UIInput(UIComponent owner) {
        super(owner);
    }

    @Override
    public void output(HtmlWriter html) {
        if (this.caption != null) {
            html.print(this.caption);
        }
        html.print("<input");

        if (getId() != null) {
            html.print(String.format(" id=\"%s\"", getId()));
        }
        if (name != null) {
            html.print(String.format(" name=\"%s\"", name));
        } else if (this.getId() != null) {
            html.print(String.format(" name=\"%s\"", getId()));
        }
        if (this.readonly) {
            html.print(" readonly=\"readonly\"");
        }
        if (value != null) {
            html.print(String.format(" value=\"%s\"", value));
        }
        if (this.hidden) {
            html.println(" type=\"hidden\" />");
            return;
        }

        if (placeholder != null) {
            html.print(" placeholder=\"%s\"", this.placeholder);
        }
        html.println("/>");
    }

    public String getCaption() {
        return caption;
    }

    @Deprecated
    public UIInput setCaption(String caption) {
        this.caption = caption;
        return this;
    }

    @Override
    public String getName() {
        if (name == null)
            name = this.getId();
        return name;
    }

    public UIInput setName(String name) {
        this.name = name;
        return this;
    }

    public String getValue() {
        return value;
    }

    public UIInput setValue(String value) {
        this.value = value;
        return this;
    }

    public boolean isReadonly() {
        return readonly;
    }

    public void setReadonly(boolean readonly) {
        this.readonly = readonly;
    }

    public String getPlaceholder() {
        return placeholder;
    }

    public void setPlaceholder(String placeholder) {
        this.placeholder = placeholder;
    }

    public boolean isHidden() {
        return hidden;
    }

    public void setHidden(boolean hidden) {
        this.hidden = hidden;
    }

}

@@ -359,16 +359,46 @@
 eholder;
+%0A    private String inputType;
 %0A%0A    pu
@@ -1234,24 +1234,143 @@
 %0A        %7D%0A%0A
+        // %E4%BB%A5%E4%B8%8B%E4%B8%BA%E9%99%84%E5%8A%A0%E5%8A%9F%E8%83%BD%0A%0A        if (inputType != null) %7B%0A            html.print(%22 type=%5C%22%25s%5C%22%22, this.inputType);%0A        %7D%0A
         if (
@@ -2547,10 +2547,170 @@
 %0A    %7D%0A%0A
+    public String getInputType() %7B%0A        return inputType;%0A    %7D%0A%0A    public void setInputType(String inputType) %7B%0A        this.inputType = inputType;%0A    %7D%0A%0A
 %7D%0A

Update UIInput.java