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.components.custom;
17:
18: import java.awt.event.ActionEvent;
19: import java.awt.event.ActionListener;
20: import org.itsnat.comp.ItsNatComponentManager;
21: import org.itsnat.comp.html.ItsNatHTMLInputButton;
22: import org.itsnat.comp.html.ItsNatHTMLInputPassword;
23: import org.itsnat.comp.html.ItsNatHTMLInputText;
24: import org.itsnat.feashow.features.components.shared.MyCustomComponentBase;
25: import org.w3c.dom.Element;
26:
27: public class LoginComponent extends MyCustomComponentBase implements
28: ActionListener {
29: protected ItsNatHTMLInputText userComp;
30: protected ItsNatHTMLInputPassword passwordComp;
31: protected ItsNatHTMLInputButton validateComp;
32: protected Element logElem;
33: protected ValidateLoginListener validateListener;
34:
35: public LoginComponent(Element parentElem,
36: ItsNatComponentManager compMgr) {
37: super (parentElem, compMgr);
38:
39: this .userComp = (ItsNatHTMLInputText) compMgr
40: .createItsNatComponentById("userId");
41: this .passwordComp = (ItsNatHTMLInputPassword) compMgr
42: .createItsNatComponentById("passwordId");
43: this .validateComp = (ItsNatHTMLInputButton) compMgr
44: .createItsNatComponentById("validateId");
45:
46: validateComp.getButtonModel().addActionListener(this );
47: }
48:
49: public void dispose() {
50: userComp.dispose();
51: passwordComp.dispose();
52: validateComp.dispose();
53: }
54:
55: public ValidateLoginListener getValidateLoginListener() {
56: return validateListener;
57: }
58:
59: public void setValidateLoginListener(ValidateLoginListener listener) {
60: this .validateListener = listener;
61: }
62:
63: public void actionPerformed(ActionEvent e) {
64: if (validateListener != null) {
65: validateListener.validate(getUser(), getPassword());
66: }
67: }
68:
69: public String getUser() {
70: return userComp.getText();
71: }
72:
73: public String getPassword() {
74: return passwordComp.getText();
75: }
76: }
|