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.listeners;
17:
18: import org.itsnat.core.ItsNatDocument;
19: import org.itsnat.core.event.NodePropertyTransport;
20: import org.itsnat.feashow.FeatureTreeNode;
21: import org.w3c.dom.Document;
22: import org.w3c.dom.events.Event;
23: import org.w3c.dom.events.EventListener;
24: import org.w3c.dom.events.EventTarget;
25: import org.w3c.dom.html.HTMLInputElement;
26:
27: public class AutoSyncPropertiesOnServerTreeNode extends FeatureTreeNode
28: implements EventListener {
29: protected HTMLInputElement inputElem;
30:
31: public AutoSyncPropertiesOnServerTreeNode() {
32: }
33:
34: public void startExamplePanel() {
35: ItsNatDocument itsNatDoc = getItsNatDocument();
36: Document doc = itsNatDoc.getDocument();
37:
38: this .inputElem = (HTMLInputElement) doc
39: .getElementById("inputElemId");
40:
41: itsNatDoc.addEventListener((EventTarget) inputElem, "change",
42: this , false, new NodePropertyTransport("value"));
43: // Alternative:
44: //itsNatDoc.addEventListener((EventTarget)inputElem,"change",this,false,new NodePropertyTransport("value",String.class));
45: }
46:
47: public void endExamplePanel() {
48: ItsNatDocument itsNatDoc = getItsNatDocument();
49: itsNatDoc.removeEventListener((EventTarget) inputElem,
50: "change", this , false);
51:
52: this .inputElem = null;
53: }
54:
55: public void handleEvent(Event evt) {
56: HTMLInputElement input = (HTMLInputElement) evt
57: .getCurrentTarget();
58: log("New value: " + input.getValue());
59: }
60:
61: }
|