Source Code Cross Referenced for NewUser.java in  » IDE-Netbeans » visualweb.api.designer » vehicleincidentreportapplication » 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 » IDE Netbeans » visualweb.api.designer » vehicleincidentreportapplication 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package vehicleincidentreportapplication;
043:
044:        import com.sun.data.provider.RowKey;
045:        import com.sun.data.provider.impl.CachedRowSetDataProvider;
046:        import com.sun.rave.web.ui.appbase.AbstractPageBean;
047:        import com.sun.sql.rowset.CachedRowSetXImpl;
048:        import com.sun.webui.jsf.component.Body;
049:        import com.sun.webui.jsf.component.Button;
050:        import com.sun.webui.jsf.component.Form;
051:        import com.sun.webui.jsf.component.Head;
052:        import com.sun.webui.jsf.component.Html;
053:        import com.sun.webui.jsf.component.Label;
054:        import com.sun.webui.jsf.component.Link;
055:        import com.sun.webui.jsf.component.Message;
056:        import com.sun.webui.jsf.component.MessageGroup;
057:        import com.sun.webui.jsf.component.Page;
058:        import com.sun.webui.jsf.component.PasswordField;
059:        import com.sun.webui.jsf.component.TextField;
060:        import javax.faces.FacesException;
061:        import javax.faces.application.FacesMessage;
062:        import javax.faces.component.UIComponent;
063:        import javax.faces.component.html.HtmlPanelGrid;
064:        import javax.faces.context.FacesContext;
065:        import javax.faces.convert.IntegerConverter;
066:        import javax.faces.validator.LengthValidator;
067:        import javax.faces.validator.ValidatorException;
068:        import javax.sql.rowset.CachedRowSet;
069:
070:        /**
071:         * <p>Page bean that corresponds to a similarly named JSP page.  This
072:         * class contains component definitions (and initialization code) for
073:         * all components that you have defined on this page, as well as
074:         * lifecycle methods and event handlers where you may add behavior
075:         * to respond to incoming events.</p>
076:         */
077:        public class NewUser extends AbstractPageBean {
078:            // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
079:            private int __placeholder;
080:
081:            /**
082:             * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
083:             * This method is automatically generated, so any user-specified code inserted
084:             * here is subject to being replaced.</p>
085:             */
086:            private void _init() throws Exception {
087:                passwordLengthValidator.setMaximum(10);
088:                passwordLengthValidator.setMinimum(6);
089:            }
090:
091:            private Page page1 = new Page();
092:
093:            public Page getPage1() {
094:                return page1;
095:            }
096:
097:            public void setPage1(Page p) {
098:                this .page1 = p;
099:            }
100:
101:            private Html html1 = new Html();
102:
103:            public Html getHtml1() {
104:                return html1;
105:            }
106:
107:            public void setHtml1(Html h) {
108:                this .html1 = h;
109:            }
110:
111:            private Head head1 = new Head();
112:
113:            public Head getHead1() {
114:                return head1;
115:            }
116:
117:            public void setHead1(Head h) {
118:                this .head1 = h;
119:            }
120:
121:            private Link link1 = new Link();
122:
123:            public Link getLink1() {
124:                return link1;
125:            }
126:
127:            public void setLink1(Link l) {
128:                this .link1 = l;
129:            }
130:
131:            private Body body1 = new Body();
132:
133:            public Body getBody1() {
134:                return body1;
135:            }
136:
137:            public void setBody1(Body b) {
138:                this .body1 = b;
139:            }
140:
141:            private Form form1 = new Form();
142:
143:            public Form getForm1() {
144:                return form1;
145:            }
146:
147:            public void setForm1(Form f) {
148:                this .form1 = f;
149:            }
150:
151:            private HtmlPanelGrid content = new HtmlPanelGrid();
152:
153:            public HtmlPanelGrid getContent() {
154:                return content;
155:            }
156:
157:            public void setContent(HtmlPanelGrid hpg) {
158:                this .content = hpg;
159:            }
160:
161:            private HtmlPanelGrid dataGrid = new HtmlPanelGrid();
162:
163:            public HtmlPanelGrid getDataGrid() {
164:                return dataGrid;
165:            }
166:
167:            public void setDataGrid(HtmlPanelGrid hpg) {
168:                this .dataGrid = hpg;
169:            }
170:
171:            private HtmlPanelGrid paddingPanel = new HtmlPanelGrid();
172:
173:            public HtmlPanelGrid getPaddingPanel() {
174:                return paddingPanel;
175:            }
176:
177:            public void setPaddingPanel(HtmlPanelGrid hpg) {
178:                this .paddingPanel = hpg;
179:            }
180:
181:            private HtmlPanelGrid messageGrid = new HtmlPanelGrid();
182:
183:            public HtmlPanelGrid getMessageGrid() {
184:                return messageGrid;
185:            }
186:
187:            public void setMessageGrid(HtmlPanelGrid hpg) {
188:                this .messageGrid = hpg;
189:            }
190:
191:            private HtmlPanelGrid contentGrid = new HtmlPanelGrid();
192:
193:            public HtmlPanelGrid getContentGrid() {
194:                return contentGrid;
195:            }
196:
197:            public void setContentGrid(HtmlPanelGrid hpg) {
198:                this .contentGrid = hpg;
199:            }
200:
201:            private MessageGroup messageGroup1 = new MessageGroup();
202:
203:            public MessageGroup getMessageGroup1() {
204:                return messageGroup1;
205:            }
206:
207:            public void setMessageGroup1(MessageGroup mg) {
208:                this .messageGroup1 = mg;
209:            }
210:
211:            private Label label1 = new Label();
212:
213:            public Label getLabel1() {
214:                return label1;
215:            }
216:
217:            public void setLabel1(Label l) {
218:                this .label1 = l;
219:            }
220:
221:            private Label label2 = new Label();
222:
223:            public Label getLabel2() {
224:                return label2;
225:            }
226:
227:            public void setLabel2(Label l) {
228:                this .label2 = l;
229:            }
230:
231:            private Label label3 = new Label();
232:
233:            public Label getLabel3() {
234:                return label3;
235:            }
236:
237:            public void setLabel3(Label l) {
238:                this .label3 = l;
239:            }
240:
241:            private Label label4 = new Label();
242:
243:            public Label getLabel4() {
244:                return label4;
245:            }
246:
247:            public void setLabel4(Label l) {
248:                this .label4 = l;
249:            }
250:
251:            private Label label5 = new Label();
252:
253:            public Label getLabel5() {
254:                return label5;
255:            }
256:
257:            public void setLabel5(Label l) {
258:                this .label5 = l;
259:            }
260:
261:            private Label label6 = new Label();
262:
263:            public Label getLabel6() {
264:                return label6;
265:            }
266:
267:            public void setLabel6(Label l) {
268:                this .label6 = l;
269:            }
270:
271:            private Message message1 = new Message();
272:
273:            public Message getMessage1() {
274:                return message1;
275:            }
276:
277:            public void setMessage1(Message m) {
278:                this .message1 = m;
279:            }
280:
281:            private Message message2 = new Message();
282:
283:            public Message getMessage2() {
284:                return message2;
285:            }
286:
287:            public void setMessage2(Message m) {
288:                this .message2 = m;
289:            }
290:
291:            private Message message3 = new Message();
292:
293:            public Message getMessage3() {
294:                return message3;
295:            }
296:
297:            public void setMessage3(Message m) {
298:                this .message3 = m;
299:            }
300:
301:            private Message message4 = new Message();
302:
303:            public Message getMessage4() {
304:                return message4;
305:            }
306:
307:            public void setMessage4(Message m) {
308:                this .message4 = m;
309:            }
310:
311:            private Message message5 = new Message();
312:
313:            public Message getMessage5() {
314:                return message5;
315:            }
316:
317:            public void setMessage5(Message m) {
318:                this .message5 = m;
319:            }
320:
321:            private Message message6 = new Message();
322:
323:            public Message getMessage6() {
324:                return message6;
325:            }
326:
327:            public void setMessage6(Message m) {
328:                this .message6 = m;
329:            }
330:
331:            private TextField userId = new TextField();
332:
333:            public TextField getUserId() {
334:                return userId;
335:            }
336:
337:            public void setUserId(TextField tf) {
338:                this .userId = tf;
339:            }
340:
341:            private TextField firstName = new TextField();
342:
343:            public TextField getFirstName() {
344:                return firstName;
345:            }
346:
347:            public void setFirstName(TextField tf) {
348:                this .firstName = tf;
349:            }
350:
351:            private TextField lastName = new TextField();
352:
353:            public TextField getLastName() {
354:                return lastName;
355:            }
356:
357:            public void setLastName(TextField tf) {
358:                this .lastName = tf;
359:            }
360:
361:            private TextField emailAddress = new TextField();
362:
363:            public TextField getEmailAddress() {
364:                return emailAddress;
365:            }
366:
367:            public void setEmailAddress(TextField tf) {
368:                this .emailAddress = tf;
369:            }
370:
371:            private PasswordField password = new PasswordField();
372:
373:            public PasswordField getPassword() {
374:                return password;
375:            }
376:
377:            public void setPassword(PasswordField pf) {
378:                this .password = pf;
379:            }
380:
381:            private PasswordField retypePassword = new PasswordField();
382:
383:            public PasswordField getRetypePassword() {
384:                return retypePassword;
385:            }
386:
387:            public void setRetypePassword(PasswordField pf) {
388:                this .retypePassword = pf;
389:            }
390:
391:            private Button register = new Button();
392:
393:            public Button getRegister() {
394:                return register;
395:            }
396:
397:            public void setRegister(Button b) {
398:                this .register = b;
399:            }
400:
401:            private LengthValidator passwordLengthValidator = new LengthValidator();
402:
403:            public LengthValidator getPasswordLengthValidator() {
404:                return passwordLengthValidator;
405:            }
406:
407:            public void setPasswordLengthValidator(LengthValidator lv) {
408:                this .passwordLengthValidator = lv;
409:            }
410:
411:            private IntegerConverter integerConverter1 = new IntegerConverter();
412:
413:            public IntegerConverter getIntegerConverter1() {
414:                return integerConverter1;
415:            }
416:
417:            public void setIntegerConverter1(IntegerConverter ic) {
418:                this .integerConverter1 = ic;
419:            }
420:
421:            // </editor-fold>
422:
423:            /**
424:             * <p>Construct a new Page bean instance.</p>
425:             */
426:            public NewUser() {
427:            }
428:
429:            /**
430:             * <p>Callback method that is called whenever a page is navigated to,
431:             * either directly via a URL, or indirectly via page navigation.
432:             * Customize this method to acquire resources that will be needed
433:             * for event handlers and lifecycle methods, whether or not this
434:             * page is performing post back processing.</p>
435:             * 
436:             * <p>Note that, if the current request is a postback, the property
437:             * values of the components do <strong>not</strong> represent any
438:             * values submitted with this request.  Instead, they represent the
439:             * property values that were saved for this view when it was rendered.</p>
440:             */
441:            @Override
442:            public void init() {
443:                // Perform initializations inherited from our superclass
444:                super .init();
445:                // Perform application initialization that must complete
446:                // *before* managed components are initialized
447:                // TODO - add your own initialiation code here
448:
449:                // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
450:                // Initialize automatically managed components
451:                // *Note* - this logic should NOT be modified
452:                try {
453:                    _init();
454:                } catch (Exception e) {
455:                    log("NewUser Initialization Failure", e);
456:                    throw e instanceof  FacesException ? (FacesException) e
457:                            : new FacesException(e);
458:                }
459:
460:                // </editor-fold>
461:                // Perform application initialization that must complete
462:                // *after* managed components are initialized
463:                // TODO - add your own initialization code here
464:            }
465:
466:            /**
467:             * <p>Callback method that is called after the component tree has been
468:             * restored, but before any event processing takes place.  This method
469:             * will <strong>only</strong> be called on a postback request that
470:             * is processing a form submit.  Customize this method to allocate
471:             * resources that will be required in your event handlers.</p>
472:             */
473:            @Override
474:            public void preprocess() {
475:            }
476:
477:            /**
478:             * <p>Callback method that is called just before rendering takes place.
479:             * This method will <strong>only</strong> be called for the page that
480:             * will actually be rendered (and not, for example, on a page that
481:             * handled a postback and then navigated to a different page).  Customize
482:             * this method to allocate resources that will be required for rendering
483:             * this page.</p>
484:             */
485:            @Override
486:            public void prerender() {
487:            }
488:
489:            /**
490:             * <p>Callback method that is called after rendering is completed for
491:             * this request, if <code>init()</code> was called (regardless of whether
492:             * or not this was the page that was actually rendered).  Customize this
493:             * method to release resources acquired in the <code>init()</code>,
494:             * <code>preprocess()</code>, or <code>prerender()</code> methods (or
495:             * acquired during execution of an event handler).</p>
496:             */
497:            @Override
498:            public void destroy() {
499:            }
500:
501:            /**
502:             * <p>Return a reference to the scoped data bean.</p>
503:             */
504:            protected ApplicationBean1 getApplicationBean1() {
505:                return (ApplicationBean1) getBean("ApplicationBean1");
506:            }
507:
508:            /**
509:             * <p>Return a reference to the scoped data bean.</p>
510:             */
511:            protected SessionBean1 getSessionBean1() {
512:                return (SessionBean1) getBean("SessionBean1");
513:            }
514:
515:            /**
516:             * <p>Return a reference to the scoped data bean.</p>
517:             */
518:            protected RequestBean1 getRequestBean1() {
519:                return (RequestBean1) getBean("RequestBean1");
520:            }
521:
522:            public String register_action() {
523:                // TODO: Process the action. Return value is a navigation
524:                // case name where null will return to the same page.
525:                //String userid = (String) getUseridfield().getText();
526:                Integer theUserId = (Integer) this .userId.getValue();
527:
528:                // check if the user with same id exists
529:                CachedRowSet passwordRowSet = new CachedRowSetXImpl();
530:                try {
531:                    passwordRowSet
532:                            .setDataSourceName("java:comp/env/jdbc/VIR_ApacheDerby");
533:                    passwordRowSet.setTableName("PASSWORD");
534:                    passwordRowSet
535:                            .setCommand("SELECT * FROM VIR.PASSWORD WHERE VIR.PASSWORD.ID="
536:                                    + theUserId.intValue());
537:                    passwordRowSet.execute();
538:                    if (passwordRowSet.next()) {
539:                        error("Choose a different user id. That used id is already in use.");
540:                        return null;
541:                    }
542:                } catch (Exception ex) {
543:                    log(ex.getMessage(), ex);
544:                    error(ex.getMessage());
545:                    return null;
546:                }
547:
548:                String theFirstName = (String) this .firstName.getText();
549:                String theLastName = (String) this .lastName.getText();
550:                String theEmailAddress = (String) this .emailAddress.getText();
551:                String thePassword = (String) this .password.getText();
552:                String theRetypePassword = (String) this .retypePassword
553:                        .getText();
554:                if (!thePassword.equals(theRetypePassword)) {
555:                    error("Passwords must match one another.");
556:                    return null;
557:                }
558:                // add the user
559:                try {
560:                    CachedRowSet employeeRowSet = new CachedRowSetXImpl();
561:                    employeeRowSet
562:                            .setDataSourceName("java:comp/env/jdbc/VIR_ApacheDerby");
563:                    employeeRowSet.setTableName("EMPLOYEE");
564:                    employeeRowSet.setCommand("SELECT * FROM VIR.EMPLOYEE");
565:                    CachedRowSetDataProvider employeeDataProvider = new CachedRowSetDataProvider();
566:                    employeeDataProvider.setCachedRowSet(employeeRowSet);
567:                    RowKey rowKey = employeeDataProvider.appendRow();
568:                    employeeDataProvider.setValue("employee.id", rowKey,
569:                            theUserId);
570:                    employeeDataProvider.setValue("employee.firstname", rowKey,
571:                            theFirstName);
572:                    employeeDataProvider.setValue("employee.lastname", rowKey,
573:                            theLastName);
574:                    employeeDataProvider.setValue("employee.email", rowKey,
575:                            theEmailAddress);
576:
577:                    employeeDataProvider.commitChanges();
578:                    employeeDataProvider.getCachedRowSet().release();
579:                    employeeDataProvider.refresh();
580:
581:                    passwordRowSet
582:                            .setDataSourceName("java:comp/env/jdbc/VIR_ApacheDerby");
583:                    passwordRowSet.setTableName("PASSWORD");
584:                    CachedRowSetDataProvider passwordDataProvider = new CachedRowSetDataProvider();
585:                    passwordDataProvider.setCachedRowSet(passwordRowSet);
586:                    rowKey = passwordDataProvider.appendRow();
587:                    passwordDataProvider.setValue("password.id", rowKey,
588:                            theUserId);
589:                    passwordDataProvider.setValue("password.password", rowKey,
590:                            thePassword);
591:                    passwordDataProvider.commitChanges();
592:                    passwordDataProvider.getCachedRowSet().release();
593:                    passwordDataProvider.refresh();
594:                } catch (Exception ex) {
595:                    log(ex.getMessage(), ex);
596:                    error(ex.getMessage());
597:                    return null;
598:                }
599:                return "login";
600:            }
601:
602:            public void emailAddress_validate(FacesContext context,
603:                    UIComponent component, Object value) {
604:                String email = (String) value;
605:                if (email.indexOf("@") == -1 || email.startsWith("@")
606:                        || email.endsWith("@")) {
607:                    throw new ValidatorException(new FacesMessage(
608:                            "Enter a valid email address."));
609:                }
610:            }
611:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.