Source Code Cross Referenced for AddVehicle.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.sql.rowset.CachedRowSetXImpl;
049:        import com.sun.webui.jsf.component.Body;
050:        import com.sun.webui.jsf.component.Button;
051:        import com.sun.webui.jsf.component.DropDown;
052:        import com.sun.webui.jsf.component.Form;
053:        import com.sun.webui.jsf.component.Head;
054:        import com.sun.webui.jsf.component.Html;
055:        import com.sun.webui.jsf.component.Label;
056:        import com.sun.webui.jsf.component.Link;
057:        import com.sun.webui.jsf.component.Message;
058:        import com.sun.webui.jsf.component.MessageGroup;
059:        import com.sun.webui.jsf.component.Page;
060:        import com.sun.webui.jsf.component.TextField;
061:        import java.sql.SQLException;
062:        import javax.faces.FacesException;
063:        import javax.faces.application.FacesMessage;
064:        import javax.faces.component.UIComponent;
065:        import javax.faces.component.html.HtmlPanelGrid;
066:        import javax.faces.context.FacesContext;
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 AddVehicle 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:                stateDataProvider
088:                        .setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.stateRowSet}"));
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 contentGrid = new HtmlPanelGrid();
162:
163:            public HtmlPanelGrid getContentGrid() {
164:                return contentGrid;
165:            }
166:
167:            public void setContentGrid(HtmlPanelGrid hpg) {
168:                this .contentGrid = hpg;
169:            }
170:
171:            private HtmlPanelGrid messagePanel1 = new HtmlPanelGrid();
172:
173:            public HtmlPanelGrid getMessagePanel1() {
174:                return messagePanel1;
175:            }
176:
177:            public void setMessagePanel1(HtmlPanelGrid hpg) {
178:                this .messagePanel1 = hpg;
179:            }
180:
181:            private MessageGroup messageGroup1 = new MessageGroup();
182:
183:            public MessageGroup getMessageGroup1() {
184:                return messageGroup1;
185:            }
186:
187:            public void setMessageGroup1(MessageGroup mg) {
188:                this .messageGroup1 = mg;
189:            }
190:
191:            private HtmlPanelGrid paddingPanel1 = new HtmlPanelGrid();
192:
193:            public HtmlPanelGrid getPaddingPanel1() {
194:                return paddingPanel1;
195:            }
196:
197:            public void setPaddingPanel1(HtmlPanelGrid hpg) {
198:                this .paddingPanel1 = hpg;
199:            }
200:
201:            private HtmlPanelGrid dataGrid = new HtmlPanelGrid();
202:
203:            public HtmlPanelGrid getDataGrid() {
204:                return dataGrid;
205:            }
206:
207:            public void setDataGrid(HtmlPanelGrid hpg) {
208:                this .dataGrid = hpg;
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 DropDown state = new DropDown();
222:
223:            public DropDown getState() {
224:                return state;
225:            }
226:
227:            public void setState(DropDown dd) {
228:                this .state = dd;
229:            }
230:
231:            private Message message1 = new Message();
232:
233:            public Message getMessage1() {
234:                return message1;
235:            }
236:
237:            public void setMessage1(Message m) {
238:                this .message1 = m;
239:            }
240:
241:            private Label label2 = new Label();
242:
243:            public Label getLabel2() {
244:                return label2;
245:            }
246:
247:            public void setLabel2(Label l) {
248:                this .label2 = l;
249:            }
250:
251:            private TextField licensePlate = new TextField();
252:
253:            public TextField getLicensePlate() {
254:                return licensePlate;
255:            }
256:
257:            public void setLicensePlate(TextField tf) {
258:                this .licensePlate = tf;
259:            }
260:
261:            private Message message2 = new Message();
262:
263:            public Message getMessage2() {
264:                return message2;
265:            }
266:
267:            public void setMessage2(Message m) {
268:                this .message2 = m;
269:            }
270:
271:            private Label label3 = new Label();
272:
273:            public Label getLabel3() {
274:                return label3;
275:            }
276:
277:            public void setLabel3(Label l) {
278:                this .label3 = l;
279:            }
280:
281:            private TextField make = new TextField();
282:
283:            public TextField getMake() {
284:                return make;
285:            }
286:
287:            public void setMake(TextField tf) {
288:                this .make = tf;
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 Label label4 = new Label();
302:
303:            public Label getLabel4() {
304:                return label4;
305:            }
306:
307:            public void setLabel4(Label l) {
308:                this .label4 = l;
309:            }
310:
311:            private TextField model = new TextField();
312:
313:            public TextField getModel() {
314:                return model;
315:            }
316:
317:            public void setModel(TextField tf) {
318:                this .model = tf;
319:            }
320:
321:            private Message message4 = new Message();
322:
323:            public Message getMessage4() {
324:                return message4;
325:            }
326:
327:            public void setMessage4(Message m) {
328:                this .message4 = m;
329:            }
330:
331:            private Label label5 = new Label();
332:
333:            public Label getLabel5() {
334:                return label5;
335:            }
336:
337:            public void setLabel5(Label l) {
338:                this .label5 = l;
339:            }
340:
341:            private TextField color = new TextField();
342:
343:            public TextField getColor() {
344:                return color;
345:            }
346:
347:            public void setColor(TextField tf) {
348:                this .color = tf;
349:            }
350:
351:            private Message message5 = new Message();
352:
353:            public Message getMessage5() {
354:                return message5;
355:            }
356:
357:            public void setMessage5(Message m) {
358:                this .message5 = m;
359:            }
360:
361:            private Button addButton = new Button();
362:
363:            public Button getAddButton() {
364:                return addButton;
365:            }
366:
367:            public void setAddButton(Button b) {
368:                this .addButton = b;
369:            }
370:
371:            private CachedRowSetDataProvider stateDataProvider = new CachedRowSetDataProvider();
372:
373:            public CachedRowSetDataProvider getStateDataProvider() {
374:                return stateDataProvider;
375:            }
376:
377:            public void setStateDataProvider(CachedRowSetDataProvider crsdp) {
378:                this .stateDataProvider = crsdp;
379:            }
380:
381:            // </editor-fold>
382:
383:            /**
384:             * <p>Construct a new Page bean instance.</p>
385:             */
386:            public AddVehicle() {
387:            }
388:
389:            /**
390:             * <p>Callback method that is called whenever a page is navigated to,
391:             * either directly via a URL, or indirectly via page navigation.
392:             * Customize this method to acquire resources that will be needed
393:             * for event handlers and lifecycle methods, whether or not this
394:             * page is performing post back processing.</p>
395:             * 
396:             * <p>Note that, if the current request is a postback, the property
397:             * values of the components do <strong>not</strong> represent any
398:             * values submitted with this request.  Instead, they represent the
399:             * property values that were saved for this view when it was rendered.</p>
400:             */
401:            @Override
402:            public void init() {
403:                // Perform initializations inherited from our superclass
404:                super .init();
405:                // Perform application initialization that must complete
406:                // *before* managed components are initialized
407:                // TODO - add your own initialiation code here
408:
409:                // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
410:                // Initialize automatically managed components
411:                // *Note* - this logic should NOT be modified
412:                try {
413:                    _init();
414:                } catch (Exception e) {
415:                    log("AddVehicle Initialization Failure", e);
416:                    throw e instanceof  FacesException ? (FacesException) e
417:                            : new FacesException(e);
418:                }
419:
420:                // </editor-fold>
421:                // Perform application initialization that must complete
422:                // *after* managed components are initialized
423:                // TODO - add your own initialization code here
424:                try {
425:                    getSessionBean1().getVehicleRowSet().setObject(1,
426:                            getSessionBean1().getLoggedInUserId());
427:                } catch (SQLException sqe) {
428:                    error(sqe.getMessage());
429:                }
430:            }
431:
432:            /**
433:             * <p>Callback method that is called after the component tree has been
434:             * restored, but before any event processing takes place.  This method
435:             * will <strong>only</strong> be called on a postback request that
436:             * is processing a form submit.  Customize this method to allocate
437:             * resources that will be required in your event handlers.</p>
438:             */
439:            @Override
440:            public void preprocess() {
441:            }
442:
443:            /**
444:             * <p>Callback method that is called just before rendering takes place.
445:             * This method will <strong>only</strong> be called for the page that
446:             * will actually be rendered (and not, for example, on a page that
447:             * handled a postback and then navigated to a different page).  Customize
448:             * this method to allocate resources that will be required for rendering
449:             * this page.</p>
450:             */
451:            @Override
452:            public void prerender() {
453:                if (this .state.getSelected() == null) {
454:                    // arbitrarily select California
455:                    this .state.setSelected("CA");
456:                }
457:            }
458:
459:            /**
460:             * <p>Callback method that is called after rendering is completed for
461:             * this request, if <code>init()</code> was called (regardless of whether
462:             * or not this was the page that was actually rendered).  Customize this
463:             * method to release resources acquired in the <code>init()</code>,
464:             * <code>preprocess()</code>, or <code>prerender()</code> methods (or
465:             * acquired during execution of an event handler).</p>
466:             */
467:            @Override
468:            public void destroy() {
469:                stateDataProvider.close();
470:            }
471:
472:            /**
473:             * <p>Return a reference to the scoped data bean.</p>
474:             */
475:            protected ApplicationBean1 getApplicationBean1() {
476:                return (ApplicationBean1) getBean("ApplicationBean1");
477:            }
478:
479:            /**
480:             * <p>Return a reference to the scoped data bean.</p>
481:             */
482:            protected SessionBean1 getSessionBean1() {
483:                return (SessionBean1) getBean("SessionBean1");
484:            }
485:
486:            /**
487:             * <p>Return a reference to the scoped data bean.</p>
488:             */
489:            protected RequestBean1 getRequestBean1() {
490:                return (RequestBean1) getBean("RequestBean1");
491:            }
492:
493:            public String addButton_action() {
494:                // TODO: Process the action. Return value is a navigation
495:                // case name where null will return to the same page.
496:                Integer loggedInUserId = getSessionBean1().getLoggedInUserId();
497:                String theStateId = (String) this .state.getSelected();
498:                String theLicensePlate = (String) this .licensePlate.getText();
499:                String theMake = (String) this .make.getText();
500:                String theModel = (String) this .model.getText();
501:                String theColor = (String) this .color.getText();
502:                try {
503:                    CachedRowSet vehicleRowSet = new CachedRowSetXImpl();
504:                    vehicleRowSet
505:                            .setDataSourceName("java:comp/env/jdbc/VIR_ApacheDerby");
506:                    vehicleRowSet.setTableName("VEHICLE");
507:                    vehicleRowSet.setCommand("SELECT * FROM VIR.VEHICLE");
508:                    CachedRowSetDataProvider vehicleDataProvider = new CachedRowSetDataProvider();
509:                    vehicleDataProvider.setCachedRowSet(vehicleRowSet);
510:                    RowKey rowKey = vehicleDataProvider.appendRow();
511:                    vehicleDataProvider.setValue("VEHICLE.stateId", rowKey,
512:                            theStateId);
513:                    vehicleDataProvider.setValue("VEHICLE.licensePlate",
514:                            rowKey, theLicensePlate);
515:                    vehicleDataProvider.setValue("VEHICLE.make", rowKey,
516:                            theMake);
517:                    vehicleDataProvider.setValue("VEHICLE.model", rowKey,
518:                            theModel);
519:                    vehicleDataProvider.setValue("VEHICLE.color", rowKey,
520:                            theColor);
521:
522:                    CachedRowSet ownerRowSet = new CachedRowSetXImpl();
523:                    ownerRowSet
524:                            .setDataSourceName("java:comp/env/jdbc/VIR_ApacheDerby");
525:                    ownerRowSet.setTableName("OWNER");
526:                    ownerRowSet.setCommand("SELECT * FROM VIR.OWNER");
527:                    CachedRowSetDataProvider ownerDataProvider = new CachedRowSetDataProvider();
528:                    ownerDataProvider.setCachedRowSet(ownerRowSet);
529:                    rowKey = ownerDataProvider.appendRow();
530:                    ownerDataProvider.setValue("OWNER.stateId", rowKey,
531:                            theStateId);
532:                    ownerDataProvider.setValue("OWNER.licensePlate", rowKey,
533:                            theLicensePlate);
534:                    ownerDataProvider.setValue("OWNER.employeeId", rowKey,
535:                            loggedInUserId);
536:
537:                    vehicleDataProvider.commitChanges();
538:                    ownerDataProvider.commitChanges();
539:                } catch (Exception e) {
540:                    error(e.getMessage());
541:                }
542:                return "vehicles";
543:            }
544:
545:            public void state_validate(FacesContext context,
546:                    UIComponent component, Object value) {
547:                String theStateId = (String) value;
548:                if (theStateId == null || theStateId.equals("any")) {
549:                    throw new ValidatorException(new FacesMessage(
550:                            "Select a valid state."));
551:                }
552:            }
553:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.