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