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 org.itsnat.comp.ItsNatComponentManager;
19: import org.itsnat.core.ItsNatDocument;
20: import org.itsnat.feashow.FeatureTreeNode;
21: import org.w3c.dom.Document;
22: import org.w3c.dom.Element;
23:
24: public class CustomComponentTreeNode extends FeatureTreeNode {
25: protected LoginComponent loginComp;
26:
27: public CustomComponentTreeNode() {
28: }
29:
30: public void startExamplePanel() {
31: final ItsNatDocument itsNatDoc = getItsNatDocument();
32: ItsNatComponentManager componentMgr = itsNatDoc
33: .getItsNatComponentManager();
34:
35: this .loginComp = (LoginComponent) componentMgr
36: .createItsNatComponentById("loginCompId", "login", null);
37:
38: ValidateLoginListener validator = new ValidateLoginListener() {
39: public boolean validate(String user, String password) {
40: if (!user.equals("admin")) {
41: log("Bad user");
42: return false;
43: }
44:
45: if (!password.equals("1234")) {
46: log("Bad password");
47: return false;
48: }
49:
50: Element loginElem = (Element) loginComp.getNode();
51: loginElem.setAttribute("style", "display:none");
52:
53: Document doc = loginElem.getOwnerDocument();
54: Element infoElem = doc.createElement("p");
55: infoElem
56: .appendChild(doc.createTextNode("VALID LOGIN!"));
57: loginElem.getParentNode().insertBefore(infoElem,
58: loginElem);
59:
60: return true;
61: }
62: };
63:
64: loginComp.setValidateLoginListener(validator);
65: }
66:
67: public void endExamplePanel() {
68: this.loginComp.dispose();
69: this.loginComp = null;
70: }
71:
72: }
|