Source Code Cross Referenced for Register.java in  » J2EE » Enhydra-Demos » transactionsDiscRack » presentation » personMgmt » 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 » J2EE » Enhydra Demos » transactionsDiscRack.presentation.personMgmt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         *
021:         * $Id: Register.java,v 1.1 2006-09-11 12:47:00 sinisa Exp $
022:         */
023:
024:        package transactionsDiscRack.presentation.personMgmt;
025:
026:        import transactionsDiscRack.presentation.BasePO;
027:        import transactionsDiscRack.presentation.TransactionsDiscRackPresentationException;
028:        import transactionsDiscRack.spec.*;
029:
030:        import com.lutris.appserver.server.httpPresentation.*;
031:        import org.enhydra.xml.xmlc.XMLObject;
032:
033:        import org.enhydra.dods.exceptions.AssertionDataObjectException;
034:
035:        /**
036:         * Register.java handles the user registration functionality
037:         * of the DiscRack app.
038:         *
039:         */
040:        public class Register extends BasePO {
041:
042:            /**
043:             * Constants
044:             */
045:            private static String LOGINNAME = "login";
046:
047:            private static String PASSWORD = "password";
048:
049:            private static String REPASSWORD = "repassword";
050:
051:            private static String FIRSTNAME = "firstname";
052:
053:            private static String LASTNAME = "lastname";
054:
055:            /**
056:             * Superclass method override
057:             */
058:            public boolean loggedInUserRequired() {
059:                return false;
060:            }
061:
062:            /**
063:             *  Default event. Just show the page.
064:             *
065:             * @return html document
066:             * @exception HttpPresentationException
067:             */
068:            public XMLObject handleDefault() throws HttpPresentationException {
069:                return showPage(null);
070:            }
071:
072:            /**
073:             *  process login data, save fields to PersonManager if correct,
074:             *  otherwise output error messages
075:             *
076:             * @return html document
077:             * @exception HttpPresentationException
078:             */
079:            public XMLObject handleRegister() throws HttpPresentationException {
080:
081:                String login = this .getComms().request.getParameter(LOGINNAME);
082:                String password = this .getComms().request
083:                        .getParameter(PASSWORD);
084:                String firstname = this .getComms().request
085:                        .getParameter(FIRSTNAME);
086:                String lastname = this .getComms().request
087:                        .getParameter(LASTNAME);
088:                String repassword = this .getComms().request
089:                        .getParameter(REPASSWORD);
090:
091:                // if login or password field is empty, generate error and redirect to this PO
092:                if (login.length() == 0 || password.length() == 0
093:                        || firstname.length() == 0 || lastname.length() == 0) {
094:                    return showPage("Missing information. Please make sure all fields are filled out exactly");
095:                }
096:
097:                //Check that password was duplicated correctly
098:                if (!repassword.equals(password)) {
099:                    return showPage("Please make sure your password and password confirmation match exactly");
100:                }
101:
102:                /*
103:                 * Catch Null pointer exception ( we canot make a instances of classes from business layer  when we run transactionsDiscRack_pres )
104:                 * We need  to allow discRack_pres to be functional ,  response
105:                 * will be default HTML page with message
106:                 */
107:                try {
108:                    Person user = ((PersonGenerator) PersonGeneratorFactory
109:                            .getPersonGenerator("transactionsDiscRack.business.person.PersonGeneratorImpl"))
110:                            .findPerson(login, this .transaction);
111:
112:                    // Now check that the login name is not taken.
113:                    if (null == user) {
114:
115:                        user = PersonFactory
116:                                .getPerson("transactionsDiscRack.business.person.PersonImpl");
117:
118:                        user.setLogin(login);
119:                        user.setPassword(password);
120:                        user.setFirstname(firstname);
121:                        user.setLastname(lastname);
122:
123:                        //Add the user to the database.
124:                        user.save(this .transaction);
125:
126:                        this .getSessionData().setUserMessage(
127:                                "You are registered, " + user.getFirstname()
128:                                        + ", please log in");
129:                        throw new ClientPageRedirectException(
130:                                getComms().request.getApplicationPath()
131:                                        + LOGIN_PAGE);
132:                    } else {
133:                        // Login name already taken
134:                        // Redirect to this same PO with informative error message
135:                        return showPage("The login name " + login
136:                                + " is already taken. Please try another.");
137:                    }
138:                } catch (AssertionDataObjectException ex) {
139:                    return showPage("Table person is read-only: can't register another person.");
140:                } catch (TransactionsDiscRackException ex) {
141:                    throw new TransactionsDiscRackPresentationException(
142:                            "Exception logging in user: ", ex);
143:                } catch (Exception ex) {
144:                    return showPage("You canot register while you in presentation mode!");
145:                }
146:            }
147:
148:            /**
149:             * display page
150:             *
151:             * @param errorMsg the error messages
152:             * @return html document
153:             * @exception HttpPresentationException
154:             */
155:            public XMLObject showPage(String errorMsg)
156:                    throws HttpPresentationException {
157:
158:                RegisterHTML page = (RegisterHTML) myComms.xmlcFactory
159:                        .create(RegisterHTML.class);
160:
161:                if (null == errorMsg) {
162:                    page.getElementErrorText().getParentNode().removeChild(
163:                            page.getElementErrorText());
164:                } else {
165:                    page.setTextErrorText(errorMsg);
166:                }
167:
168:                if (null != this.getComms().request.getParameter(LOGINNAME)) {
169:                    page.getElementLogin().setValue(
170:                            this.getComms().request.getParameter(LOGINNAME));
171:                }
172:                if (null != this.getComms().request.getParameter(FIRSTNAME)) {
173:                    page.getElementFirstname().setValue(
174:                            this.getComms().request.getParameter(FIRSTNAME));
175:                }
176:                if (null != this.getComms().request.getParameter(LASTNAME)) {
177:                    page.getElementLastname().setValue(
178:                            this.getComms().request.getParameter(LASTNAME));
179:                }
180:
181:                return page;
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.