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


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         *
0026:         * The Original Software is NetBeans. The Initial Developer of the Original
0027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028:         * Microsystems, Inc. All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         */
0041:
0042:        /*
0043:         * Page1.java
0044:         *
0045:         * Created on Aug 3, 2007, 11:02:03 AM
0046:         * by jb144761
0047:         *
0048:         */
0049:        package singlepagecrudtable;
0050:
0051:        import com.sun.data.provider.RowKey;
0052:        import com.sun.data.provider.TableCursorVetoException;
0053:        import com.sun.data.provider.impl.CachedRowSetDataProvider;
0054:        import com.sun.data.provider.impl.TableRowDataProvider;
0055:        import com.sun.rave.web.ui.appbase.AbstractPageBean;
0056:        import com.sun.sql.rowset.CachedRowSetXImpl;
0057:        import com.sun.webui.jsf.component.Body;
0058:        import com.sun.webui.jsf.component.Button;
0059:        import com.sun.webui.jsf.component.Calendar;
0060:        import com.sun.webui.jsf.component.Checkbox;
0061:        import com.sun.webui.jsf.component.DropDown;
0062:        import com.sun.webui.jsf.component.Form;
0063:        import com.sun.webui.jsf.component.Head;
0064:        import com.sun.webui.jsf.component.Html;
0065:        import com.sun.webui.jsf.component.Label;
0066:        import com.sun.webui.jsf.component.Link;
0067:        import com.sun.webui.jsf.component.Message;
0068:        import com.sun.webui.jsf.component.Page;
0069:        import com.sun.webui.jsf.component.StaticText;
0070:        import com.sun.webui.jsf.component.Table;
0071:        import com.sun.webui.jsf.component.TableColumn;
0072:        import com.sun.webui.jsf.component.TableRowGroup;
0073:        import com.sun.webui.jsf.component.TextField;
0074:        import com.sun.webui.jsf.model.SingleSelectOptionsList;
0075:        import java.sql.SQLException;
0076:        import java.util.HashSet;
0077:        import java.util.Iterator;
0078:        import java.util.Set;
0079:        import javax.faces.FacesException;
0080:        import javax.faces.application.FacesMessage;
0081:        import javax.faces.component.UIComponent;
0082:        import javax.faces.component.UIInput;
0083:        import javax.faces.component.html.HtmlPanelGrid;
0084:        import javax.faces.context.FacesContext;
0085:        import javax.faces.convert.IntegerConverter;
0086:        import javax.faces.event.ValueChangeEvent;
0087:        import javax.faces.validator.ValidatorException;
0088:
0089:        /**
0090:         * <p>Page bean that corresponds to a similarly named JSP page.  This
0091:         * class contains component definitions (and initialization code) for
0092:         * all components that you have defined on this page, as well as
0093:         * lifecycle methods and event handlers where you may add behavior
0094:         * to respond to incoming events.</p>
0095:         */
0096:        public class Page1 extends AbstractPageBean {
0097:            // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
0098:            private int __placeholder;
0099:
0100:            /**
0101:             * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
0102:             * This method is automatically generated, so any user-specified code inserted
0103:             * here is subject to being replaced.</p>
0104:             */
0105:            private void _init() throws Exception {
0106:                tripDataProvider
0107:                        .setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.tripRowSet}"));
0108:                personDataProvider
0109:                        .setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.personRowSet}"));
0110:                triptypeDataProvider
0111:                        .setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.triptypeRowSet}"));
0112:            }
0113:
0114:            private Page page1 = new Page();
0115:
0116:            public Page getPage1() {
0117:                return page1;
0118:            }
0119:
0120:            public void setPage1(Page p) {
0121:                this .page1 = p;
0122:            }
0123:
0124:            private Html html1 = new Html();
0125:
0126:            public Html getHtml1() {
0127:                return html1;
0128:            }
0129:
0130:            public void setHtml1(Html h) {
0131:                this .html1 = h;
0132:            }
0133:
0134:            private Head head1 = new Head();
0135:
0136:            public Head getHead1() {
0137:                return head1;
0138:            }
0139:
0140:            public void setHead1(Head h) {
0141:                this .head1 = h;
0142:            }
0143:
0144:            private Link link1 = new Link();
0145:
0146:            public Link getLink1() {
0147:                return link1;
0148:            }
0149:
0150:            public void setLink1(Link l) {
0151:                this .link1 = l;
0152:            }
0153:
0154:            private Body body1 = new Body();
0155:
0156:            public Body getBody1() {
0157:                return body1;
0158:            }
0159:
0160:            public void setBody1(Body b) {
0161:                this .body1 = b;
0162:            }
0163:
0164:            private Form form1 = new Form();
0165:
0166:            public Form getForm1() {
0167:                return form1;
0168:            }
0169:
0170:            public void setForm1(Form f) {
0171:                this .form1 = f;
0172:            }
0173:
0174:            private HtmlPanelGrid mainPanel = new HtmlPanelGrid();
0175:
0176:            public HtmlPanelGrid getMainPanel() {
0177:                return mainPanel;
0178:            }
0179:
0180:            public void setMainPanel(HtmlPanelGrid hpg) {
0181:                this .mainPanel = hpg;
0182:            }
0183:
0184:            private HtmlPanelGrid personInfoPanel = new HtmlPanelGrid();
0185:
0186:            public HtmlPanelGrid getPersonInfoPanel() {
0187:                return personInfoPanel;
0188:            }
0189:
0190:            public void setPersonInfoPanel(HtmlPanelGrid hpg) {
0191:                this .personInfoPanel = hpg;
0192:            }
0193:
0194:            private HtmlPanelGrid tripsPanel = new HtmlPanelGrid();
0195:
0196:            public HtmlPanelGrid getTripsPanel() {
0197:                return tripsPanel;
0198:            }
0199:
0200:            public void setTripsPanel(HtmlPanelGrid hpg) {
0201:                this .tripsPanel = hpg;
0202:            }
0203:
0204:            private HtmlPanelGrid addTripParentPanel = new HtmlPanelGrid();
0205:
0206:            public HtmlPanelGrid getAddTripParentPanel() {
0207:                return addTripParentPanel;
0208:            }
0209:
0210:            public void setAddTripParentPanel(HtmlPanelGrid hpg) {
0211:                this .addTripParentPanel = hpg;
0212:            }
0213:
0214:            private HtmlPanelGrid headerPanel = new HtmlPanelGrid();
0215:
0216:            public HtmlPanelGrid getHeaderPanel() {
0217:                return headerPanel;
0218:            }
0219:
0220:            public void setHeaderPanel(HtmlPanelGrid hpg) {
0221:                this .headerPanel = hpg;
0222:            }
0223:
0224:            private HtmlPanelGrid newTripInfoPanel = new HtmlPanelGrid();
0225:
0226:            public HtmlPanelGrid getNewTripInfoPanel() {
0227:                return newTripInfoPanel;
0228:            }
0229:
0230:            public void setNewTripInfoPanel(HtmlPanelGrid hpg) {
0231:                this .newTripInfoPanel = hpg;
0232:            }
0233:
0234:            private HtmlPanelGrid footerPanel = new HtmlPanelGrid();
0235:
0236:            public HtmlPanelGrid getFooterPanel() {
0237:                return footerPanel;
0238:            }
0239:
0240:            public void setFooterPanel(HtmlPanelGrid hpg) {
0241:                this .footerPanel = hpg;
0242:            }
0243:
0244:            private Table trips = new Table();
0245:
0246:            public Table getTrips() {
0247:                return trips;
0248:            }
0249:
0250:            public void setTrips(Table t) {
0251:                this .trips = t;
0252:            }
0253:
0254:            private TableRowGroup tableRowGroup1 = new TableRowGroup();
0255:
0256:            public TableRowGroup getTableRowGroup1() {
0257:                return tableRowGroup1;
0258:            }
0259:
0260:            public void setTableRowGroup1(TableRowGroup trg) {
0261:                this .tableRowGroup1 = trg;
0262:            }
0263:
0264:            private HtmlPanelGrid buttonsPanel = new HtmlPanelGrid();
0265:
0266:            public HtmlPanelGrid getButtonsPanel() {
0267:                return buttonsPanel;
0268:            }
0269:
0270:            public void setButtonsPanel(HtmlPanelGrid hpg) {
0271:                this .buttonsPanel = hpg;
0272:            }
0273:
0274:            private Button updateButton = new Button();
0275:
0276:            public Button getUpdateButton() {
0277:                return updateButton;
0278:            }
0279:
0280:            public void setUpdateButton(Button b) {
0281:                this .updateButton = b;
0282:            }
0283:
0284:            private Button deleteButton = new Button();
0285:
0286:            public Button getDeleteButton() {
0287:                return deleteButton;
0288:            }
0289:
0290:            public void setDeleteButton(Button b) {
0291:                this .deleteButton = b;
0292:            }
0293:
0294:            private Label label1 = new Label();
0295:
0296:            public Label getLabel1() {
0297:                return label1;
0298:            }
0299:
0300:            public void setLabel1(Label l) {
0301:                this .label1 = l;
0302:            }
0303:
0304:            private DropDown personId = new DropDown();
0305:
0306:            public DropDown getPersonId() {
0307:                return personId;
0308:            }
0309:
0310:            public void setPersonId(DropDown dd) {
0311:                this .personId = dd;
0312:            }
0313:
0314:            private Label label2 = new Label();
0315:
0316:            public Label getLabel2() {
0317:                return label2;
0318:            }
0319:
0320:            public void setLabel2(Label l) {
0321:                this .label2 = l;
0322:            }
0323:
0324:            private StaticText jobTitle = new StaticText();
0325:
0326:            public StaticText getJobTitle() {
0327:                return jobTitle;
0328:            }
0329:
0330:            public void setJobTitle(StaticText st) {
0331:                this .jobTitle = st;
0332:            }
0333:
0334:            private Label label3 = new Label();
0335:
0336:            public Label getLabel3() {
0337:                return label3;
0338:            }
0339:
0340:            public void setLabel3(Label l) {
0341:                this .label3 = l;
0342:            }
0343:
0344:            private Message message1 = new Message();
0345:
0346:            public Message getMessage1() {
0347:                return message1;
0348:            }
0349:
0350:            public void setMessage1(Message m) {
0351:                this .message1 = m;
0352:            }
0353:
0354:            private StaticText staticText4 = new StaticText();
0355:
0356:            public StaticText getStaticText4() {
0357:                return staticText4;
0358:            }
0359:
0360:            public void setStaticText4(StaticText st) {
0361:                this .staticText4 = st;
0362:            }
0363:
0364:            private Label label4 = new Label();
0365:
0366:            public Label getLabel4() {
0367:                return label4;
0368:            }
0369:
0370:            public void setLabel4(Label l) {
0371:                this .label4 = l;
0372:            }
0373:
0374:            private Calendar departureDate = new Calendar();
0375:
0376:            public Calendar getDepartureDate() {
0377:                return departureDate;
0378:            }
0379:
0380:            public void setDepartureDate(Calendar c) {
0381:                this .departureDate = c;
0382:            }
0383:
0384:            private Message message2 = new Message();
0385:
0386:            public Message getMessage2() {
0387:                return message2;
0388:            }
0389:
0390:            public void setMessage2(Message m) {
0391:                this .message2 = m;
0392:            }
0393:
0394:            private Label label5 = new Label();
0395:
0396:            public Label getLabel5() {
0397:                return label5;
0398:            }
0399:
0400:            public void setLabel5(Label l) {
0401:                this .label5 = l;
0402:            }
0403:
0404:            private DropDown tripType = new DropDown();
0405:
0406:            public DropDown getTripType() {
0407:                return tripType;
0408:            }
0409:
0410:            public void setTripType(DropDown dd) {
0411:                this .tripType = dd;
0412:            }
0413:
0414:            private Message message3 = new Message();
0415:
0416:            public Message getMessage3() {
0417:                return message3;
0418:            }
0419:
0420:            public void setMessage3(Message m) {
0421:                this .message3 = m;
0422:            }
0423:
0424:            private Label label6 = new Label();
0425:
0426:            public Label getLabel6() {
0427:                return label6;
0428:            }
0429:
0430:            public void setLabel6(Label l) {
0431:                this .label6 = l;
0432:            }
0433:
0434:            private TextField departureCity = new TextField();
0435:
0436:            public TextField getDepartureCity() {
0437:                return departureCity;
0438:            }
0439:
0440:            public void setDepartureCity(TextField tf) {
0441:                this .departureCity = tf;
0442:            }
0443:
0444:            private Label label7 = new Label();
0445:
0446:            public Label getLabel7() {
0447:                return label7;
0448:            }
0449:
0450:            public void setLabel7(Label l) {
0451:                this .label7 = l;
0452:            }
0453:
0454:            private TextField destinationCity = new TextField();
0455:
0456:            public TextField getDestinationCity() {
0457:                return destinationCity;
0458:            }
0459:
0460:            public void setDestinationCity(TextField tf) {
0461:                this .destinationCity = tf;
0462:            }
0463:
0464:            private Message message4 = new Message();
0465:
0466:            public Message getMessage4() {
0467:                return message4;
0468:            }
0469:
0470:            public void setMessage4(Message m) {
0471:                this .message4 = m;
0472:            }
0473:
0474:            private StaticText staticText5 = new StaticText();
0475:
0476:            public StaticText getStaticText5() {
0477:                return staticText5;
0478:            }
0479:
0480:            public void setStaticText5(StaticText st) {
0481:                this .staticText5 = st;
0482:            }
0483:
0484:            private Message message5 = new Message();
0485:
0486:            public Message getMessage5() {
0487:                return message5;
0488:            }
0489:
0490:            public void setMessage5(Message m) {
0491:                this .message5 = m;
0492:            }
0493:
0494:            private Button addButton = new Button();
0495:
0496:            public Button getAddButton() {
0497:                return addButton;
0498:            }
0499:
0500:            public void setAddButton(Button b) {
0501:                this .addButton = b;
0502:            }
0503:
0504:            private CachedRowSetDataProvider tripDataProvider = new CachedRowSetDataProvider();
0505:
0506:            public CachedRowSetDataProvider getTripDataProvider() {
0507:                return tripDataProvider;
0508:            }
0509:
0510:            public void setTripDataProvider(CachedRowSetDataProvider crsdp) {
0511:                this .tripDataProvider = crsdp;
0512:            }
0513:
0514:            private TableColumn tableColumn3 = new TableColumn();
0515:
0516:            public TableColumn getTableColumn3() {
0517:                return tableColumn3;
0518:            }
0519:
0520:            public void setTableColumn3(TableColumn tc) {
0521:                this .tableColumn3 = tc;
0522:            }
0523:
0524:            private TableColumn tableColumn4 = new TableColumn();
0525:
0526:            public TableColumn getTableColumn4() {
0527:                return tableColumn4;
0528:            }
0529:
0530:            public void setTableColumn4(TableColumn tc) {
0531:                this .tableColumn4 = tc;
0532:            }
0533:
0534:            private TableColumn tableColumn5 = new TableColumn();
0535:
0536:            public TableColumn getTableColumn5() {
0537:                return tableColumn5;
0538:            }
0539:
0540:            public void setTableColumn5(TableColumn tc) {
0541:                this .tableColumn5 = tc;
0542:            }
0543:
0544:            private TableColumn tableColumn6 = new TableColumn();
0545:
0546:            public TableColumn getTableColumn6() {
0547:                return tableColumn6;
0548:            }
0549:
0550:            public void setTableColumn6(TableColumn tc) {
0551:                this .tableColumn6 = tc;
0552:            }
0553:
0554:            private TableColumn tableColumn8 = new TableColumn();
0555:
0556:            public TableColumn getTableColumn8() {
0557:                return tableColumn8;
0558:            }
0559:
0560:            public void setTableColumn8(TableColumn tc) {
0561:                this .tableColumn8 = tc;
0562:            }
0563:
0564:            private Checkbox selectedTripCheckbox = new Checkbox();
0565:
0566:            public Checkbox getSelectedTripCheckbox() {
0567:                return selectedTripCheckbox;
0568:            }
0569:
0570:            public void setSelectedTripCheckbox(Checkbox c) {
0571:                this .selectedTripCheckbox = c;
0572:            }
0573:
0574:            private TextField tripsDepartureDate = new TextField();
0575:
0576:            public TextField getTripsDepartureDate() {
0577:                return tripsDepartureDate;
0578:            }
0579:
0580:            public void setTripsDepartureDate(TextField tf) {
0581:                this .tripsDepartureDate = tf;
0582:            }
0583:
0584:            private TextField tripsDestinationCity = new TextField();
0585:
0586:            public TextField getTripsDestinationCity() {
0587:                return tripsDestinationCity;
0588:            }
0589:
0590:            public void setTripsDestinationCity(TextField tf) {
0591:                this .tripsDestinationCity = tf;
0592:            }
0593:
0594:            private DropDown tripsTripType = new DropDown();
0595:
0596:            public DropDown getTripsTripType() {
0597:                return tripsTripType;
0598:            }
0599:
0600:            public void setTripsTripType(DropDown dd) {
0601:                this .tripsTripType = dd;
0602:            }
0603:
0604:            private TextField tripsDepartureCity = new TextField();
0605:
0606:            public TextField getTripsDepartureCity() {
0607:                return tripsDepartureCity;
0608:            }
0609:
0610:            public void setTripsDepartureCity(TextField tf) {
0611:                this .tripsDepartureCity = tf;
0612:            }
0613:
0614:            private Message message6 = new Message();
0615:
0616:            public Message getMessage6() {
0617:                return message6;
0618:            }
0619:
0620:            public void setMessage6(Message m) {
0621:                this .message6 = m;
0622:            }
0623:
0624:            private Message message7 = new Message();
0625:
0626:            public Message getMessage7() {
0627:                return message7;
0628:            }
0629:
0630:            public void setMessage7(Message m) {
0631:                this .message7 = m;
0632:            }
0633:
0634:            private Message message8 = new Message();
0635:
0636:            public Message getMessage8() {
0637:                return message8;
0638:            }
0639:
0640:            public void setMessage8(Message m) {
0641:                this .message8 = m;
0642:            }
0643:
0644:            private Message message9 = new Message();
0645:
0646:            public Message getMessage9() {
0647:                return message9;
0648:            }
0649:
0650:            public void setMessage9(Message m) {
0651:                this .message9 = m;
0652:            }
0653:
0654:            private CachedRowSetDataProvider personDataProvider = new CachedRowSetDataProvider();
0655:
0656:            public CachedRowSetDataProvider getPersonDataProvider() {
0657:                return personDataProvider;
0658:            }
0659:
0660:            public void setPersonDataProvider(CachedRowSetDataProvider crsdp) {
0661:                this .personDataProvider = crsdp;
0662:            }
0663:
0664:            private IntegerConverter personIdConverter = new IntegerConverter();
0665:
0666:            public IntegerConverter getPersonIdConverter() {
0667:                return personIdConverter;
0668:            }
0669:
0670:            public void setPersonIdConverter(IntegerConverter ic) {
0671:                this .personIdConverter = ic;
0672:            }
0673:
0674:            private CachedRowSetDataProvider triptypeDataProvider = new CachedRowSetDataProvider();
0675:
0676:            public CachedRowSetDataProvider getTriptypeDataProvider() {
0677:                return triptypeDataProvider;
0678:            }
0679:
0680:            public void setTriptypeDataProvider(CachedRowSetDataProvider crsdp) {
0681:                this .triptypeDataProvider = crsdp;
0682:            }
0683:
0684:            private IntegerConverter tripsTripTypeConverter = new IntegerConverter();
0685:
0686:            public IntegerConverter getTripsTripTypeConverter() {
0687:                return tripsTripTypeConverter;
0688:            }
0689:
0690:            public void setTripsTripTypeConverter(IntegerConverter ic) {
0691:                this .tripsTripTypeConverter = ic;
0692:            }
0693:
0694:            private IntegerConverter tripTypeConverter = new IntegerConverter();
0695:
0696:            public IntegerConverter getTripTypeConverter() {
0697:                return tripTypeConverter;
0698:            }
0699:
0700:            public void setTripTypeConverter(IntegerConverter ic) {
0701:                this .tripTypeConverter = ic;
0702:            }
0703:
0704:            // </editor-fold>
0705:
0706:            /**
0707:             * <p>Construct a new Page bean instance.</p>
0708:             */
0709:            public Page1() {
0710:            }
0711:
0712:            /**
0713:             * <p>Callback method that is called whenever a page is navigated to,
0714:             * either directly via a URL, or indirectly via page navigation.
0715:             * Customize this method to acquire resources that will be needed
0716:             * for event handlers and lifecycle methods, whether or not this
0717:             * page is performing post back processing.</p>
0718:             * 
0719:             * <p>Note that, if the current request is a postback, the property
0720:             * values of the components do <strong>not</strong> represent any
0721:             * values submitted with this request.  Instead, they represent the
0722:             * property values that were saved for this view when it was rendered.</p>
0723:             */
0724:            public void init() {
0725:                // Perform initializations inherited from our superclass
0726:                super .init();
0727:                // Perform application initialization that must complete
0728:                // *before* managed components are initialized
0729:                // TODO - add your own initialiation code here
0730:
0731:                // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
0732:                // Initialize automatically managed components
0733:                // *Note* - this logic should NOT be modified
0734:                try {
0735:                    _init();
0736:                } catch (Exception e) {
0737:                    log("Page1 Initialization Failure", e);
0738:                    throw e instanceof  FacesException ? (FacesException) e
0739:                            : new FacesException(e);
0740:                }
0741:
0742:                // </editor-fold>
0743:                // Perform application initialization that must complete
0744:                // *after* managed components are initialized
0745:                // TODO - add your own initialization code here
0746:                // Restore the current person
0747:                RowKey personRowKey = getSessionBean1()
0748:                        .getCurrentPersonRowKey();
0749:                Integer pid = (Integer) personDataProvider
0750:                        .getValue("PERSON.PERSONID");
0751:                if (personRowKey == null) {
0752:                    personDataProvider.cursorFirst();
0753:                    personRowKey = personDataProvider.getCursorRow();
0754:                    try {
0755:                        getSessionBean1().getTripRowSet().setObject(1, pid);
0756:                        getSessionBean1().getTripRowSet().execute();
0757:                        tripDataProvider.cursorFirst();
0758:                    } catch (Exception ex) {
0759:                        log("Error Description", ex);
0760:                    }
0761:                } else {
0762:                    personDataProvider.setCursorRow(personRowKey);
0763:                }
0764:                personId.setSelected(pid);
0765:            }
0766:
0767:            /**
0768:             * <p>Callback method that is called after the component tree has been
0769:             * restored, but before any event processing takes place.  This method
0770:             * will <strong>only</strong> be called on a postback request that
0771:             * is processing a form submit.  Customize this method to allocate
0772:             * resources that will be required in your event handlers.</p>
0773:             */
0774:            public void preprocess() {
0775:            }
0776:
0777:            /**
0778:             * <p>Callback method that is called just before rendering takes place.
0779:             * This method will <strong>only</strong> be called for the page that
0780:             * will actually be rendered (and not, for example, on a page that
0781:             * handled a postback and then navigated to a different page).  Customize
0782:             * this method to allocate resources that will be required for rendering
0783:             * this page.</p>
0784:             */
0785:            public void prerender() {
0786:            }
0787:
0788:            /**
0789:             * <p>Callback method that is called after rendering is completed for
0790:             * this request, if <code>init()</code> was called (regardless of whether
0791:             * or not this was the page that was actually rendered).  Customize this
0792:             * method to release resources acquired in the <code>init()</code>,
0793:             * <code>preprocess()</code>, or <code>prerender()</code> methods (or
0794:             * acquired during execution of an event handler).</p>
0795:             */
0796:            public void destroy() {
0797:                getSessionBean1().setCurrentPersonRowKey(
0798:                        personDataProvider.getCursorRow());
0799:                tripDataProvider.close();
0800:                personDataProvider.close();
0801:                triptypeDataProvider.close();
0802:            }
0803:
0804:            /**
0805:             * <p>Return a reference to the scoped data bean.</p>
0806:             */
0807:            protected RequestBean1 getRequestBean1() {
0808:                return (RequestBean1) getBean("RequestBean1");
0809:            }
0810:
0811:            /**
0812:             * <p>Return a reference to the scoped data bean.</p>
0813:             */
0814:            protected SessionBean1 getSessionBean1() {
0815:                return (SessionBean1) getBean("SessionBean1");
0816:            }
0817:
0818:            /**
0819:             * <p>Return a reference to the scoped data bean.</p>
0820:             */
0821:            protected ApplicationBean1 getApplicationBean1() {
0822:                return (ApplicationBean1) getBean("ApplicationBean1");
0823:            }
0824:
0825:            public void personId_processValueChange(ValueChangeEvent event) {
0826:                Integer newPersonId = (Integer) personId.getSelected();
0827:                // Find the datatable's row that matches the dropdown's
0828:                // selected person
0829:                RowKey rowKey = personDataProvider.findFirst("PERSON.PERSONID",
0830:                        newPersonId);
0831:                // just in case someone deleted row after dropdown was populated
0832:                if (rowKey != null) {
0833:                    try {
0834:                        // change cursor position
0835:                        personDataProvider.setCursorRow(rowKey);
0836:                        getSessionBean1().getTripRowSet().setObject(1,
0837:                                newPersonId);
0838:                        getSessionBean1().getTripRowSet().execute();
0839:                        tripDataProvider.cursorFirst();
0840:                    } catch (TableCursorVetoException tcve) {
0841:                        error("Cannot change to personId " + newPersonId);
0842:                    } catch (SQLException sqle) {
0843:                        error("Problem with trip table");
0844:                    }
0845:                } else {
0846:                    // exceptional event we might want to know about
0847:                    log("Missing person for personId " + newPersonId);
0848:                    error("Missing person for personId " + newPersonId);
0849:                }
0850:                form1.discardSubmittedValues("saveChanges");
0851:            }
0852:
0853:            public String updateButton_action() {
0854:                // TODO: Process the action. Return value is a navigation
0855:                // case name where null will return to the same page.
0856:                // case name where null will return to the same page.
0857:                try {
0858:                    tripDataProvider.commitChanges();
0859:                } catch (Exception e) {
0860:                    error("Cannot commit updates: " + e);
0861:                }
0862:                return null;
0863:            }
0864:
0865:            /* The set of RowKeys for rows that have been selected.
0866:             * This set is manipulated by calls to setSelectedTrip(),
0867:             * which will occur when the checkbox of each row is decoded.
0868:             */
0869:            private Set<RowKey> selectedTrips = new HashSet<RowKey>();
0870:
0871:            public String deleteButton_action() {
0872:                // TODO: Process the action. Return value is a navigation
0873:                // case name where null will return to the same page.
0874:                Iterator rowKeys = selectedTrips.iterator();
0875:                while (rowKeys.hasNext()) {
0876:                    RowKey rowKey = (RowKey) rowKeys.next();
0877:                    System.out.println("rowKey: " + rowKey);
0878:                    try {
0879:                        tripDataProvider.removeRow(rowKey);
0880:                    } catch (Exception e) {
0881:                        error("Cannot delete trip with row key " + rowKey);
0882:                    }
0883:                }
0884:                // do outside loop because commitChanges() invalidates rowkeys
0885:                try {
0886:                    tripDataProvider.commitChanges();
0887:                } catch (Exception ex) {
0888:                    error("Cannot commit deletions.");
0889:                }
0890:                return null;
0891:            }
0892:
0893:            /**
0894:             * Returns true if the trip for the current row is selected.
0895:             */
0896:            public boolean isSelectedTrip() {
0897:                TableRowDataProvider trdp = (TableRowDataProvider) getBean("currentRow");
0898:                if (trdp == null) {
0899:                    return false;
0900:                }
0901:                RowKey rowKey = trdp.getTableRow();
0902:                return selectedTrips.contains(rowKey);
0903:            }
0904:
0905:            /**
0906:             * Records whether or not the current trip should be marked as selected,
0907:             * based on the state of the checkbox.
0908:             */
0909:            public void setSelectedTrip(boolean b) {
0910:                TableRowDataProvider trdp = (TableRowDataProvider) getBean("currentRow");
0911:                RowKey rowKey = trdp.getTableRow();
0912:                if (selectedTripCheckbox.isChecked()) {
0913:                    selectedTrips.add(rowKey);
0914:                } else {
0915:                    selectedTrips.remove(rowKey);
0916:                }
0917:            }
0918:
0919:            public String addButton_action() {
0920:                // TODO: Process the action. Return value is a navigation
0921:                // case name where null will return to the same page.
0922:                if (tripDataProvider.canAppendRow()) {
0923:                    try {
0924:                        RowKey rowKey = tripDataProvider.appendRow();
0925:                        tripDataProvider.setCursorRow(rowKey);
0926:                        tripDataProvider.setValue("TRIP.TRIPID", rowKey,
0927:                                nextPK());
0928:                        tripDataProvider.setValue("TRIP.PERSONID", rowKey,
0929:                                personId.getSelected());
0930:                        java.util.Date depDate = (java.util.Date) departureDate
0931:                                .getValue();
0932:                        if (depDate != null) {
0933:                            java.sql.Date date = new java.sql.Date(depDate
0934:                                    .getTime());
0935:                            tripDataProvider.setValue("TRIP.DEPDATE", rowKey,
0936:                                    date);
0937:                        } else {
0938:                            tripDataProvider.setValue("TRIP.DEPDATE", rowKey,
0939:                                    null);
0940:                        }
0941:                        tripDataProvider.setValue("TRIP.DEPCITY", rowKey,
0942:                                departureCity.getValue());
0943:                        tripDataProvider.setValue("TRIP.DESTCITY", rowKey,
0944:                                destinationCity.getValue());
0945:                        tripDataProvider.setValue("TRIP.TRIPTYPEID", rowKey,
0946:                                tripType.getSelected());
0947:                        tripDataProvider.commitChanges();
0948:                    } catch (Exception e) {
0949:                        error("Cannot append new trip: " + e);
0950:                    }
0951:                } else {
0952:                    error("Cannot append a new row");
0953:                }
0954:                //clear fields
0955:                departureDate.setValue(null);
0956:                departureCity.setText(null);
0957:                destinationCity.setText(null);
0958:                tripType.setForgetValue(true);
0959:                form1.discardSubmittedValues("saveChanges");
0960:                return null;
0961:            }
0962:
0963:            // Generate an integer Primary Key
0964:            // Return next primary key for TRAVEL.TRIP table
0965:            private Integer nextPK() throws SQLException {
0966:                // create a new rowset
0967:                CachedRowSetXImpl pkRowSet = new CachedRowSetXImpl();
0968:                try {
0969:                    // set the rowset to use the Travel database
0970:                    pkRowSet
0971:                            .setDataSourceName("java:comp/env/jdbc/TRAVEL_ApacheDerby");
0972:                    // find the highest person id and add one to it
0973:                    pkRowSet
0974:                            .setCommand("SELECT MAX(TRAVEL.TRIP.TRIPID) + 1 FROM TRAVEL.TRIP");
0975:                    pkRowSet.setTableName("TRAVEL.TRIP");
0976:                    // execute the rowset -- which will contain a single row and single column
0977:                    pkRowSet.execute();
0978:                    pkRowSet.next();
0979:                    // get the key
0980:                    int counter = pkRowSet.getInt(1);
0981:                    return new Integer(counter);
0982:                } catch (Exception e) {
0983:                    error("Error fetching Max(TRAVEL.TRIP.TRIPID) + 1 : "
0984:                            + e.getMessage());
0985:                } finally {
0986:                    pkRowSet.close();
0987:                }
0988:                return null;
0989:            }
0990:
0991:            private void containsNoDigits(FacesContext fc, UIComponent uic,
0992:                    Object value, String errorMessage) {
0993:                String name = (String) value;
0994:                for (int i = 0; i < name.length(); i++) {
0995:                    if (Character.isDigit(name.charAt(i))) {
0996:                        ((UIInput) uic).setValid(false);
0997:                        throw new ValidatorException(new FacesMessage(
0998:                                errorMessage));
0999:                    }
1000:                }
1001:            }
1002:
1003:            public void departureCity_validate(FacesContext context,
1004:                    UIComponent component, Object value) {
1005:                containsNoDigits(context, component, value,
1006:                        "City names cannot contain digits.");
1007:            }
1008:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.