001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.impl.comp.html;
015:
016: import org.itsnat.comp.html.ItsNatHTMLForm;
017: import org.itsnat.comp.ui.ItsNatComponentUI;
018: import javax.swing.ButtonModel;
019: import org.itsnat.core.event.ParamTransport;
020: import org.itsnat.core.NameValue;
021: import org.itsnat.impl.comp.html.ui.ItsNatHTMLFormUIImpl;
022: import org.itsnat.impl.core.html.ItsNatHTMLDocumentImpl;
023: import org.w3c.dom.Document;
024: import org.w3c.dom.Node;
025: import org.w3c.dom.html.HTMLFormElement;
026:
027: /**
028: *
029: * @author jmarranz
030: */
031: public class ItsNatHTMLFormImpl extends ItsNatHTMLElementComponentImpl
032: implements ItsNatHTMLForm {
033: /**
034: * Creates a new instance of ItsNatHTMLFormImpl
035: */
036: public ItsNatHTMLFormImpl(HTMLFormElement element,
037: NameValue[] artifacts,
038: ItsNatHTMLComponentManagerImpl componentMgr) {
039: super (element, artifacts, componentMgr);
040:
041: init();
042: }
043:
044: public void enableEventListeners() {
045: // No activamos nada porque por defecto no se hace nada
046: // cuando el usuario añada un listener se activarán automáticamente
047:
048: //enableEventListener("submit");
049: //enableEventListener("reset");
050: }
051:
052: public HTMLFormElement getHTMLFormElement() {
053: return (HTMLFormElement) getHTMLElement();
054: }
055:
056: public void setDefaultDataModel() {
057: // Nada que hacer, no hay modelo
058: }
059:
060: public ItsNatComponentUI createDefaultItsNatComponentUI() {
061: return new ItsNatHTMLFormUIImpl(this );
062: }
063:
064: public void bindDataModel() {
065: // No hay modelo
066: }
067:
068: public void unbindDataModel() {
069: // No hay modelo
070: }
071:
072: public void submit() {
073: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
074: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
075: getHTMLElement(), "submit", new Object[0], true);
076: }
077:
078: public void reset() {
079: ItsNatHTMLDocumentImpl itsNatDoc = getItsNatHTMLDocumentImpl();
080: itsNatDoc.getJSScriptUtilImpl().callNodeMethod(
081: getHTMLElement(), "reset", new Object[0], true);
082: }
083:
084: public Object createDefaultModelInternal() {
085: return null; // No hay modelo
086: }
087:
088: public ButtonModel createDefaultButtonModel() {
089: return null; // No hay modelo
090: }
091:
092: protected ParamTransport[] getParamTransports(String type) {
093: return null;
094: }
095:
096: public void syncUIWithDataModel() {
097: // no hay modelo
098: }
099:
100: public Node createDefaultNode() {
101: Document doc = getItsNatDocument().getDocument();
102: HTMLFormElement form = (HTMLFormElement) doc
103: .createElement("form");
104: return form;
105: }
106:
107: }
|