18 package org.turro.html;
20 import java.io.IOException;
21 import java.util.Iterator;
23 import org.turro.elephant.context.ElephantContext;
24 import org.turro.elephant.context.IElement;
39 public void startForm(String
id, String method, String actionElement) {
40 startForm(
id, method, actionElement,
"class='htmlform'");
43 public void startForm(String
id, String method, String actionElement, String attributes) {
45 "/xpaction/" + actionElement;
46 write(
"<form id='" +
id +
"' action='" + formAction +
"' method='" + method +
"' " + attributes +
">");
47 createHiddenElement();
52 "/xpaction/" + actionElement;
53 write(
"<form id='" +
id +
"' action='" + formAction +
"' method='" + method +
"' enctype='multipart/form-data' class='htmlform'>");
54 createHiddenElement();
62 doTag(
"input",
new String[] {
65 "name='action_" +
command +
"'",
66 "style='" + style +
"'",
67 "value=\"" + value +
"\""
71 public void command(String
command, String value, String style, String onClick) {
72 doTag(
"input",
new String[] {
75 "name='action_" +
command +
"'",
76 "style='" + style +
"'",
77 "onclick=\"javascript:" + onClick +
"\"",
78 "value=\"" + value +
"\""
83 doTag(
"input",
new String[] {
86 "onclick='javascript:" +
command +
"'",
87 "style='" + style +
"'",
88 "value=\"" + value +
"\""
95 "onclick='showEdit" +
id +
"(this)'",
98 "style='cursor:pointer'"
100 textInput(
id, value, style +
";display:none");
103 "function showEdit" +
id +
"(el) {" +
105 "$('" + idShow +
"').hide();" +
106 "$('" +
id +
"').show();" +
112 public void textInput(String
id, String value, String style) {
113 if(value ==
null) value =
"";
114 write(
"<input type='text' name='" +
id +
"' id='" +
id +
"' value='" + value +
"' style='" + style +
"' class='hf_input'/>");
118 if(value ==
null) value =
"";
119 write(
"<input type='password' name='" +
id +
"' id='" +
id +
"' value='" + value +
"' style='" + style +
"' class='hf_input'/>");
122 public void checkBox(String
id, String value, String style,
boolean checked) {
123 if(value ==
null) value =
"";
124 write(
"<input type='checkbox' name='" +
id +
"' id='" +
id +
"' value='" + value +
"' style='" + style +
"' class='hf_check'" + (checked ?
" checked" :
"") +
"/>");
130 "onclick='showEdit" +
id +
"(this)'",
133 "style='cursor:pointer'"
135 textArea(
id, value, style +
";display:none");
138 "function showEdit" +
id +
"(el) {" +
140 "$('" + idShow +
"').hide();" +
141 "$('" +
id +
"').show();" +
147 public void textArea(String
id, String value, String style) {
148 if(value ==
null) value =
"";
149 write(
"<textarea name='" +
id +
"' id='" +
id +
"' style='" + style +
"' class='hf_editor'>" + value +
"</textarea>");
152 public void selectList(String
id, String value, Map options, String style) {
153 write(
"<select name='" +
id +
"' id='" +
id +
"' style='" + style +
"' class='hf_select'>");
154 Iterator it = options.keySet().iterator();
156 while(it.hasNext()) {
157 key = (String)it.next();
158 write(
"<option value='" + key +
"'");
159 if(key.equals(value)) {
163 write((String)options.get(key));
169 public void hidden(String
id, String value) {
170 write(
"<input type='hidden' name='" +
id +
"' value='" + value +
"'/>");
173 public void inPlaceAutocompleter(String idShow, String
id, String value, String style, String actionElement, String action, String extraParam, String tokenizer) {
176 "onclick='showEdit" +
id +
"(this)'",
179 "style='cursor:pointer'"
181 autocompleter(
id, value, style +
";display:none", actionElement, action, extraParam, tokenizer);
184 "function showEdit" +
id +
"(el) {" +
186 (idShow !=
null ?
"$('" + idShow +
"').hide();" :
"") +
187 "$('" +
id +
"').show();" +
193 public void autocompleter(String
id, String value, String style, String actionElement, String action, String extraParam, String tokenizer) {
195 "/xpaction/" + actionElement +
196 "?action=" + action +
201 if(value ==
null) value =
"";
202 write(
"<input type='text' id='" +
id +
"' name='" +
id +
"' value='" + value +
"' style='" + style +
"' class='hf_autocompleter'/>");
203 String idList =
"ac_" + id;
204 startTag(
"div",
new String[] {
"id='" + idList +
"'",
"class='autolist'" });
208 "new Ajax.Autocompleter(\n" +
209 "\"" +
id +
"\", \"" + idList +
"\"," +
210 "\"" + formAction +
"\"" +
211 (tokenizer !=
null ?
", {tokens:\"" + tokenizer +
"\"}" :
"") +
218 write(
"<input type='file' name='" +
id +
"' style='" + style +
"' class='hf_upload'/>");
221 private void createHiddenElement() {
static String getRootWebPath()
HTMLGenerator doTag(String tag)
HTMLGenerator startTag(String tag)
HTMLGenerator endJavaScript()
HTMLGenerator startJavaScript()
void writeln(String value)
HTMLGenerator write(String value)