Source Code Cross Referenced for Login.java in  » Web-Framework » Millstone » org » millstone » examples » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » Millstone » org.millstone.examples 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.millstone.examples;
002:
003:        import org.millstone.base.Application;
004:        import org.millstone.base.ui.*;
005:        import org.millstone.base.data.*;
006:
007:        /** <p>Example application demonstrating simple user login.</p>
008:         *
009:         * @author IT Mill Ltd.
010:         * @see org.millstone.base.service.Application
011:         * @see org.millstone.base.ui.Window
012:         * @see org.millstone.base.ui.TextField
013:         * @see org.millstone.base.ui.Button
014:         */
015:        public class Login extends Application implements 
016:                Property.ValueChangeListener {
017:
018:            /* Menu for navigating inside the application. */
019:            private Tree menu = new Tree();
020:
021:            /* Contents of the website */
022:            private String[][] pages = {
023:                    { "Welcome", "Welcome to out website..." },
024:                    { "Products", "Public product information." },
025:                    { "Contact", "Public contact information." },
026:                    { "CRM", "CRM Database requiring login." },
027:                    { "Intranet", "Internal information database." } };
028:
029:            /* Application layout */
030:            private GridLayout layout = new GridLayout(2, 1);
031:
032:            /* Initialize the application */
033:            public void init() {
034:
035:                // Create the main window of the application
036:                Window main = new Window("Login example", layout);
037:                setMainWindow(main);
038:
039:                // Add menu and loginbox to the application
040:                OrderedLayout l = new OrderedLayout();
041:                layout.addComponent(l, 0, 0);
042:                l.addComponent(menu);
043:                l.addComponent(new LoginBox());
044:
045:                // Setup menu
046:                menu.setStyle("menu");
047:                menu.addListener(this );
048:                menu.setImmediate(true);
049:                addToMenu(new String[] { "Welcome", "Products", "Contact" });
050:            }
051:
052:            // Overriding usetUser method is a simple way of updating application
053:            // privileges when the user is changed 
054:            public void setUser(Object user) {
055:                super .setUser(user);
056:                if (user != null)
057:                    addToMenu(new String[] { "CRM", "Intranet" });
058:            }
059:
060:            public void addToMenu(String[] items) {
061:                for (int i = 0; i < items.length; i++) {
062:                    menu.addItem(items[i]);
063:                    menu.setChildrenAllowed(items[i], false);
064:                }
065:                if (menu.getValue() == null)
066:                    menu.setValue(items[0]);
067:            }
068:
069:            // Handle menu selection and update visible page
070:            public void valueChange(Property.ValueChangeEvent event) {
071:                layout.removeComponent(1, 0);
072:                String title = (String) menu.getValue();
073:                for (int i = 0; i < pages.length; i++)
074:                    if (pages[i][0].equals(title)) {
075:                        Panel p = new Panel(pages[i][0]);
076:                        p.addComponent(new Label(pages[i][1]));
077:                        p.setStyle("strong");
078:                        layout.addComponent(p, 1, 0);
079:                    }
080:            }
081:
082:            // Simple loginbox component for the application
083:            public class LoginBox extends CustomComponent implements 
084:                    Application.UserChangeListener {
085:
086:                // The components this loginbox is composed of
087:                private TextField loginName = new TextField("Name");
088:                private Button loginButton = new Button("Enter", this , "login");
089:                private Panel loginPanel = new Panel("Login");
090:                private Panel statusPanel = new Panel();
091:                private Button logoutButton = new Button("Logout", Login.this ,
092:                        "close");
093:                private Label statusLabel = new Label();
094:
095:                // Initialize login component
096:                public LoginBox() {
097:
098:                    // Initialize the component
099:                    loginPanel.addComponent(loginName);
100:                    loginPanel.addComponent(loginButton);
101:                    loginPanel.setStyle("strong");
102:                    loginButton.dependsOn(loginName);
103:                    loginName.setColumns(8);
104:                    statusPanel.addComponent(statusLabel);
105:                    statusPanel.addComponent(logoutButton);
106:
107:                    // Set the status of the loginbox and show correct components
108:                    updateStatus();
109:
110:                    // Listen application user change events
111:                    Login.this .addListener(this );
112:                }
113:
114:                // Login into application
115:                public void login() {
116:                    String name = (String) loginName.getValue();
117:                    if (name != null && name.length() > 0)
118:                        setUser(name);
119:                    loginName.setValue("");
120:                }
121:
122:                // Update login status on application user change events
123:                public void applicationUserChanged(
124:                        Application.UserChangeEvent event) {
125:                    updateStatus();
126:                }
127:
128:                // Update login status of the component by exposing correct components
129:                private void updateStatus() {
130:                    statusLabel.setValue("User: " + getUser());
131:                    if (getUser() != null)
132:                        setCompositionRoot(statusPanel);
133:                    else
134:                        setCompositionRoot(loginPanel);
135:                }
136:            }
137:        }
138:
139:        /* This Millstone sample code is public domain. *  
140:         * For more information see www.millstone.org.  */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.