KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > control > Edit


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.gui.control;
14
15 import info.magnolia.cms.core.Content;
16
17
18 /**
19  * @author Vinzenz Wyser
20  * @version 2.0
21  */

22 public class Edit extends ControlImpl {
23
24     String JavaDoc rows = "1"; //$NON-NLS-1$
25

26     public Edit() {
27     }
28
29     public Edit(String JavaDoc name, String JavaDoc value) {
30         super(name, value);
31     }
32
33     public Edit(String JavaDoc name, Content websiteNode) {
34         super(name, websiteNode);
35     }
36
37     public void setRows(String JavaDoc s) {
38         this.rows = s;
39     }
40
41     public String JavaDoc getRows() {
42         return this.rows;
43     }
44
45     public String JavaDoc getHtml() {
46         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
47         String JavaDoc id = this.getId();
48         if (id == null) {
49             id = this.getName();
50         }
51         if (this.getRows().equals("1")) { //$NON-NLS-1$
52
html.append("<input type=\"text\""); //$NON-NLS-1$
53
html.append(" name=\"" + this.getName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
54
html.append(" id=\"" + id + "\""); //$NON-NLS-1$ //$NON-NLS-2$
55
html.append(" value=\"" + ControlImpl.escapeHTML(this.getValue()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
56
html.append(getHtmlEvents());
57             html.append(this.getHtmlCssClass());
58             html.append(this.getHtmlCssStyles());
59             html.append(" />"); //$NON-NLS-1$
60
}
61         else {
62             html.append("<textarea"); //$NON-NLS-1$
63
html.append(" name=\"" + this.getName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
64
html.append(" id=\"" + id + "\""); //$NON-NLS-1$ //$NON-NLS-2$
65
html.append(" rows=\"" + this.getRows() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
66
html.append(this.getHtmlCssClass());
67             html.append(this.getHtmlCssStyles());
68             html.append(getHtmlEvents());
69             html.append(">"); //$NON-NLS-1$
70
html.append(this.getValue());
71             html.append("</textarea>"); //$NON-NLS-1$
72
}
73         if (this.getSaveInfo()) {
74             html.append(this.getHtmlSaveInfo());
75         }
76         return html.toString();
77     }
78 }
79
Popular Tags