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: package org.itsnat.feashow.features.core;
16:
17: import org.itsnat.core.ItsNatDocument;
18: import org.w3c.dom.Document;
19: import org.w3c.dom.Element;
20: import org.w3c.dom.events.Event;
21: import org.w3c.dom.events.EventListener;
22: import org.w3c.dom.events.EventTarget;
23: import org.w3c.dom.html.HTMLDocument;
24:
25: public class PrettyURLListener implements EventListener {
26: protected ItsNatDocument itsNatDoc;
27:
28: public PrettyURLListener(ItsNatDocument itsNatDoc) {
29: this .itsNatDoc = itsNatDoc;
30: load();
31: }
32:
33: public void load() {
34: Document doc = itsNatDoc.getDocument();
35:
36: Element elem = doc.getElementById("elemId");
37:
38: itsNatDoc.addEventListener((EventTarget) elem, "click", this ,
39: false);
40: }
41:
42: public void handleEvent(Event evt) {
43: HTMLDocument doc = (HTMLDocument) itsNatDoc.getDocument();
44: Element p = doc.createElement("p");
45: p.appendChild(doc.createTextNode("Clicked"));
46: doc.getBody().appendChild(p);
47: }
48:
49: }
|