01: /*
02: * This file is not part of the ItsNat framework.
03: *
04: * Original source code use and closed source derivatives are authorized
05: * to third parties with no restriction or fee.
06: * The original source code is owned by the author.
07: *
08: * This program is distributed AS IS in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * Author: Jose Maria Arranz Santamaria
13: * (C) Innowhere Software Services S.L., Spanish company, year 2007
14: */
15:
16: package org.itsnat.feashow.features.core;
17:
18: import org.itsnat.core.ItsNatDocument;
19: import org.itsnat.core.script.ScriptUtil;
20: import org.itsnat.feashow.FeatureTreeNode;
21: import org.w3c.dom.Document;
22: import org.w3c.dom.html.HTMLTextAreaElement;
23:
24: public class JavaToJavaScriptGenTreeNode extends FeatureTreeNode {
25: public JavaToJavaScriptGenTreeNode() {
26: }
27:
28: public void startExamplePanel() {
29: ItsNatDocument itsNatDoc = getItsNatDocument();
30: Document doc = itsNatDoc.getDocument();
31:
32: HTMLTextAreaElement textAreaElem = (HTMLTextAreaElement) doc
33: .getElementById("textAreaId");
34:
35: ScriptUtil scriptGen = itsNatDoc.getScriptUtil();
36:
37: String code;
38: String msg = "A Java String 'transported' \n\t as a \"JavaScript\" string";
39:
40: String textAreaElemJS = scriptGen
41: .getNodeReference(textAreaElem);
42: String jsStrLiteral = scriptGen
43: .getTransportableStringLiteral(msg);
44: code = textAreaElemJS + ".value = " + jsStrLiteral + ";";
45: itsNatDoc.addCodeToSend(code);
46: log(code);
47:
48: code = scriptGen.getSetPropertyCode(textAreaElem, "value", msg,
49: true);
50: itsNatDoc.addCodeToSend(code);
51: log(code);
52:
53: code = scriptGen.getCallMethodCode(textAreaElem, "select",
54: null, true);
55: itsNatDoc.addCodeToSend(code);
56: log(code);
57: }
58:
59: public void endExamplePanel() {
60:
61: }
62: }
|