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.comp.html;
15:
16: import org.itsnat.comp.html.ItsNatHTMLInput;
17: import org.itsnat.core.NameValue;
18: import org.itsnat.impl.core.html.ItsNatHTMLDocumentImpl;
19: import org.itsnat.impl.core.domutil.ItsNatDOMUtilInternal;
20: import org.w3c.dom.Node;
21: import org.w3c.dom.html.HTMLFormElement;
22: import org.w3c.dom.html.HTMLInputElement;
23:
24: /**
25: *
26: * @author jmarranz
27: */
28: public abstract class ItsNatHTMLInputImpl extends
29: ItsNatHTMLFormCompValueBasedImpl implements ItsNatHTMLInput {
30:
31: /**
32: * Creates a new instance of ItsNatHTMLInputImpl
33: */
34: public ItsNatHTMLInputImpl(HTMLInputElement element,
35: NameValue[] artifacts,
36: ItsNatHTMLComponentManagerImpl componentMgr) {
37: super (element, artifacts, componentMgr);
38:
39: ItsNatDOMUtilInternal.setAttribute(getHTMLInputElement(),
40: "type", getExpectedType()); // para asegurarnos (actualmente sobra, se hace también en el modelo interno)
41: }
42:
43: public HTMLInputElement getHTMLInputElement() {
44: return (HTMLInputElement) getHTMLElement();
45: }
46:
47: public HTMLFormElement getHTMLFormElement() {
48: return getHTMLInputElement().getForm();
49: }
50:
51: public abstract String getExpectedType();
52:
53: public void blur() {
54: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
55: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
56: getHTMLElement(), "blur", new Object[0], true);
57: }
58:
59: public void focus() {
60: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
61: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
62: getHTMLElement(), "focus", new Object[0], true);
63: }
64:
65: public void click() {
66: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
67: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
68: getHTMLElement(), "click", new Object[0], true);
69: }
70:
71: public void select() {
72: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
73: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
74: getHTMLElement(), "select", new Object[0], true);
75: }
76:
77: public Node createDefaultNode() {
78: HTMLInputElement elem = (HTMLInputElement) getItsNatDocument()
79: .getDocument().createElement("input");
80: ItsNatDOMUtilInternal.setAttribute(elem, "type",
81: getExpectedType());
82: return elem;
83: }
84:
85: }
|