package cn.cerc.ui.vcl;

import cn.cerc.ui.core.HtmlWriter;
import cn.cerc.ui.parts.UIComponent;
import cn.cerc.ui.vcl.ext.UISpan;

/**
 * 多行文本输入框
 *
 * @author 黄荣君
 */
public class UITextArea extends UIComponent {
    private UISpan caption;
    private String name;
    private String text;
    private String placeholder;
    private int cols;
    private int rows;
    private boolean readonly;

    public UITextArea() {
    }

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

    @Override
    public void output(HtmlWriter html) {
        if (caption != null) {
            caption.output(html);
        }

        html.print("<textarea ");
        if (this.getId() != null) {
            html.print(" id='%s'", this.getId());
        }
        if (name != null) {
            html.print("name='%s' ", name);
        }
        if (cols != 0) {
            html.print("rows='%s' ", cols);
        }
        if (rows != 0) {
            html.print("rows='%s' ", rows);
        }
        if (placeholder != null) {
            html.print("placeholder=%s ", placeholder);
        }
        if (readonly) {
            html.print("readonly='readonly'");
        }
        super.outputCss(html);
        html.print(">");

        if (text != null) {
            html.print(text);
        }
        html.print("</textarea>");
    }

    public UISpan getCaption() {
        if (caption == null)
            caption = new UISpan();
        return caption;
    }

    public void setCaption(UISpan caption) {
        this.caption = caption;
    }

    public String getName() {
        return name;
    }

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

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getPlaceholder() {
        return placeholder;
    }

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

    public int getCols() {
        return cols;
    }

    public void setCols(int cols) {
        this.cols = cols;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public boolean isReadonly() {
        return readonly;
    }

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

}

@@ -335,24 +335,28 @@
 te int cols;
+// %E5%88%97
 %0A    private
@@ -361,24 +361,28 @@
 te int rows;
+// %E8%A1%8C
 %0A    private
@@ -862,19 +862,19 @@
     if (
-col
+row
 s != 0) 
@@ -912,19 +912,19 @@
 '%25s' %22, 
-col
+row
 s);%0A    
@@ -933,35 +933,35 @@
   %7D%0A        if (
-row
+col
 s != 0) %7B%0A      
@@ -970,35 +970,35 @@
     html.print(%22
-row
+col
 s='%25s' %22, rows);
@@ -983,35 +983,35 @@
 t(%22cols='%25s' %22, 
-row
+col
 s);%0A        %7D%0A  
@@ -1418,16 +1418,18 @@
 == null)
+ %7B
 %0A       
@@ -1457,16 +1457,26 @@
 Span();%0A
+        %7D%0A
         
@@ -1505,28 +1505,34 @@
 %0A    public 
-void
+UITextArea
  setCaption(
@@ -1573,32 +1573,53 @@
 tion = caption;%0A
+        return this;%0A
     %7D%0A%0A    publi
@@ -1674,28 +1674,34 @@
 %0A    public 
-void
+UITextArea
  setName(Str
@@ -1734,24 +1734,45 @@
 ame = name;%0A
+        return this;%0A
     %7D%0A%0A    p
@@ -1831,28 +1831,34 @@
 %0A    public 
-void
+UITextArea
  setText(Str
@@ -1891,24 +1891,45 @@
 ext = text;%0A
+        return this;%0A
     %7D%0A%0A    p
@@ -2002,28 +2002,34 @@
 %0A    public 
-void
+UITextArea
  setPlacehol
@@ -2086,32 +2086,53 @@
  = placeholder;%0A
+        return this;%0A
     %7D%0A%0A    publi
@@ -2184,28 +2184,34 @@
 %0A    public 
-void
+UITextArea
  setCols(int
@@ -2241,24 +2241,45 @@
 ols = cols;%0A
+        return this;%0A
     %7D%0A%0A    p
@@ -2335,28 +2335,34 @@
 %0A    public 
-void
+UITextArea
  setRows(int
@@ -2392,24 +2392,45 @@
 ows = rows;%0A
+        return this;%0A
     %7D%0A%0A    p
@@ -2501,20 +2501,26 @@
  public 
-void
+UITextArea
  setRead
@@ -2574,21 +2574,42 @@
 = readonly;%0A
+        return this;%0A
     %7D%0A%0A%7D%0A

修复 UITextArea 组件行列显示错误的问题