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: /*
043: * SessionBean1.java
044: *
045: * Created on Aug 3, 2007, 11:02:03 AM
046: * by jb144761
047: *
048: */
049: package singlepagecrudtable;
050:
051: import com.sun.data.provider.RowKey;
052: import com.sun.rave.web.ui.appbase.AbstractSessionBean;
053: import com.sun.sql.rowset.CachedRowSetXImpl;
054: import javax.faces.FacesException;
055:
056: /**
057: * <p>Session scope data bean for your application. Create properties
058: * here to represent cached data that should be made available across
059: * multiple HTTP requests for an individual user.</p>
060: *
061: * <p>An instance of this class will be created for you automatically,
062: * the first time your application evaluates a value binding expression
063: * or method binding expression that references a managed bean using
064: * this class.</p>
065: */
066: public class SessionBean1 extends AbstractSessionBean {
067: // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
068: private int __placeholder;
069:
070: /**
071: * <p>Automatically managed component initialization. <strong>WARNING:</strong>
072: * This method is automatically generated, so any user-specified code inserted
073: * here is subject to being replaced.</p>
074: */
075: private void _init() throws Exception {
076: tripRowSet
077: .setDataSourceName("java:comp/env/jdbc/TRAVEL_ApacheDerby");
078: tripRowSet
079: .setCommand("SELECT ALL \"TRAVEL\".\"TRIP\".\"TRIPID\", \n \"TRAVEL\".\"TRIP\".\"PERSONID\", \n \"TRAVEL\".\"TRIP\".\"DEPDATE\", \n \"TRAVEL\".\"TRIP\".\"DEPCITY\", \n \"TRAVEL\".\"TRIP\".\"DESTCITY\", \n \"TRAVEL\".\"TRIP\".\"TRIPTYPEID\", \n \"TRAVEL\".\"TRIP\".\"LASTUPDATED\", \n \"TRAVEL\".\"TRIPTYPE\".\"NAME\" \nFROM TRAVEL.TRIP\n INNER JOIN \"TRAVEL\".\"TRIPTYPE\" ON \"TRAVEL\".\"TRIP\".\"TRIPTYPEID\" = \"TRAVEL\".\"TRIPTYPE\".\"TRIPTYPEID\"\nWHERE \"TRAVEL\".\"TRIP\".\"PERSONID\" = ? ");
080: tripRowSet.setTableName("TRIP");
081: personRowSet
082: .setDataSourceName("java:comp/env/jdbc/TRAVEL_ApacheDerby");
083: personRowSet.setCommand("SELECT * FROM TRAVEL.PERSON");
084: personRowSet.setTableName("PERSON");
085: triptypeRowSet
086: .setDataSourceName("java:comp/env/jdbc/TRAVEL_ApacheDerby");
087: triptypeRowSet.setCommand("SELECT * FROM TRAVEL.TRIPTYPE");
088: triptypeRowSet.setTableName("TRIPTYPE");
089: }
090:
091: private CachedRowSetXImpl tripRowSet = new CachedRowSetXImpl();
092:
093: public CachedRowSetXImpl getTripRowSet() {
094: return tripRowSet;
095: }
096:
097: public void setTripRowSet(CachedRowSetXImpl crsxi) {
098: this .tripRowSet = crsxi;
099: }
100:
101: private CachedRowSetXImpl personRowSet = new CachedRowSetXImpl();
102:
103: public CachedRowSetXImpl getPersonRowSet() {
104: return personRowSet;
105: }
106:
107: public void setPersonRowSet(CachedRowSetXImpl crsxi) {
108: this .personRowSet = crsxi;
109: }
110:
111: private CachedRowSetXImpl triptypeRowSet = new CachedRowSetXImpl();
112:
113: public CachedRowSetXImpl getTriptypeRowSet() {
114: return triptypeRowSet;
115: }
116:
117: public void setTriptypeRowSet(CachedRowSetXImpl crsxi) {
118: this .triptypeRowSet = crsxi;
119: }
120:
121: // </editor-fold>
122:
123: /**
124: * <p>Construct a new session data bean instance.</p>
125: */
126: public SessionBean1() {
127: }
128:
129: /**
130: * <p>This method is called when this bean is initially added to
131: * session scope. Typically, this occurs as a result of evaluating
132: * a value binding or method binding expression, which utilizes the
133: * managed bean facility to instantiate this bean and store it into
134: * session scope.</p>
135: *
136: * <p>You may customize this method to initialize and cache data values
137: * or resources that are required for the lifetime of a particular
138: * user session.</p>
139: */
140: public void init() {
141: // Perform initializations inherited from our superclass
142: super .init();
143: // Perform application initialization that must complete
144: // *before* managed components are initialized
145: // TODO - add your own initialiation code here
146:
147: // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
148: // Initialize automatically managed components
149: // *Note* - this logic should NOT be modified
150: try {
151: _init();
152: } catch (Exception e) {
153: log("SessionBean1 Initialization Failure", e);
154: throw e instanceof FacesException ? (FacesException) e
155: : new FacesException(e);
156: }
157:
158: // </editor-fold>
159: // Perform application initialization that must complete
160: // *after* managed components are initialized
161: // TODO - add your own initialization code here
162: }
163:
164: /**
165: * <p>This method is called when the session containing it is about to be
166: * passivated. Typically, this occurs in a distributed servlet container
167: * when the session is about to be transferred to a different
168: * container instance, after which the <code>activate()</code> method
169: * will be called to indicate that the transfer is complete.</p>
170: *
171: * <p>You may customize this method to release references to session data
172: * or resources that can not be serialized with the session itself.</p>
173: */
174: public void passivate() {
175: }
176:
177: /**
178: * <p>This method is called when the session containing it was
179: * reactivated.</p>
180: *
181: * <p>You may customize this method to reacquire references to session
182: * data or resources that could not be serialized with the
183: * session itself.</p>
184: */
185: public void activate() {
186: }
187:
188: /**
189: * <p>This method is called when this bean is removed from
190: * session scope. Typically, this occurs as a result of
191: * the session timing out or being terminated by the application.</p>
192: *
193: * <p>You may customize this method to clean up resources allocated
194: * during the execution of the <code>init()</code> method, or
195: * at any later time during the lifetime of the application.</p>
196: */
197: public void destroy() {
198: }
199:
200: /**
201: * <p>Return a reference to the scoped data bean.</p>
202: */
203: protected ApplicationBean1 getApplicationBean1() {
204: return (ApplicationBean1) getBean("ApplicationBean1");
205: }
206:
207: private RowKey currentPersonRowKey;
208:
209: public RowKey getCurrentPersonRowKey() {
210: return currentPersonRowKey;
211: }
212:
213: public void setCurrentPersonRowKey(RowKey currentPersonRowKey) {
214: this.currentPersonRowKey = currentPersonRowKey;
215: }
216: }
|