01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.impl.core.event.client2serv.dom;
15:
16: import org.itsnat.core.ItsNatException;
17: import org.itsnat.core.event.DOMEvent;
18: import org.itsnat.impl.core.ItsNatServletRequestImpl;
19: import org.itsnat.impl.core.event.EventInternal;
20: import org.itsnat.impl.core.event.client2serv.DOMBasedEventImpl;
21: import org.itsnat.impl.core.listener.dom.DOMEventListenerWrapperImpl;
22: import org.w3c.dom.Node;
23:
24: /**
25: * Quizás en el futuro se podría usar REX:
26: * http://www.w3.org/TR/rex/
27: Algo parecido anterior:
28: http://xmldb-org.sourceforge.net/xupdate/xupdate-wd.html
29: *
30: * @author jmarranz
31: */
32: public abstract class DOMEventImpl extends DOMBasedEventImpl implements
33: DOMEvent {
34: protected NodeContainer target;
35:
36: /** Creates a new instance of EventBaseImpl */
37: public DOMEventImpl(DOMEventListenerWrapperImpl listenerWrapper,
38: ItsNatServletRequestImpl request) {
39: super (listenerWrapper, request);
40: }
41:
42: public static String getDOMEventParam(
43: ItsNatServletRequestImpl itsNatRequest, String name) {
44: name = "itsnat_dom_" + name;
45: String param = itsNatRequest.getParameterOrAttribute(name);
46: if (param == null)
47: throw new ItsNatException(name
48: + " parameter is not specified");
49: return param;
50: }
51:
52: public String getDOMEventParam(String name) {
53: return getDOMEventParam(getItsNatServletRequestImpl(), name);
54: }
55:
56: public boolean getDOMEventParamBoolean(String name) {
57: return Boolean.valueOf(getDOMEventParam(name)).booleanValue();
58: }
59:
60: public short getDOMEventParamShort(String name) {
61: return Short.parseShort(getDOMEventParam(name));
62: }
63:
64: public int getDOMEventParamInt(String name) {
65: return Integer.parseInt(getDOMEventParam(name));
66: }
67:
68: public long getDOMEventParamLong(String name) {
69: return Long.parseLong(getDOMEventParam(name));
70: }
71:
72: public Node getDOMEventParamNode(String name) {
73: String path = getDOMEventParam(name);
74: return getItsNatDocumentImpl().getNodeFromStringPathFromClient(
75: path);
76: }
77:
78: }
|