01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.jsp.util;
16:
17: import java.io.IOException;
18: import java.io.Writer;
19:
20: /**
21: * UiStd script utilities.
22: *
23: * @author Oleg Mürk
24: */
25: public abstract class JspScriptUtil {
26: /**
27: * Writes out event handling attribute that does nothing.
28: */
29: public static void writeEmptyEventAttribute(Writer out,
30: String attributeName) throws IOException {
31: JspUtil.writeOpenAttribute(out, attributeName);
32: out.write("javascript: return false;");
33: JspUtil.writeCloseAttribute(out);
34: }
35:
36: /**
37: * Writes 'undefined' or object's string representation.
38: */
39: public static void writeObject(Writer out, Object o)
40: throws IOException {
41: out.write(o == null ? "undefined" : o.toString());
42: }
43:
44: public static void writeElementAttributeScript(Writer out,
45: String elementId, String attribute, String value)
46: throws IOException {
47: out.write("<script type=\"text/javascript\">");
48: out.write("document.getElementById('" + elementId + "')."
49: + attribute + "=" + value + ";");
50: out.write("</script>");
51: }
52: }
|