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 travelcenter;
043:
044: import com.sun.data.provider.impl.CachedRowSetDataProvider;
045: import com.sun.rave.web.ui.appbase.AbstractPageBean;
046: import com.sun.webui.jsf.component.Body;
047: import com.sun.webui.jsf.component.Button;
048: import com.sun.webui.jsf.component.DropDown;
049: import com.sun.webui.jsf.component.Form;
050: import com.sun.webui.jsf.component.Head;
051: import com.sun.webui.jsf.component.Html;
052: import com.sun.webui.jsf.component.Label;
053: import com.sun.webui.jsf.component.Link;
054: import com.sun.webui.jsf.component.Message;
055: import com.sun.webui.jsf.component.MessageGroup;
056: import com.sun.webui.jsf.component.Page;
057: import com.sun.webui.jsf.component.StaticText;
058: import com.sun.webui.jsf.component.Table;
059: import com.sun.webui.jsf.component.TableColumn;
060: import com.sun.webui.jsf.component.TableRowGroup;
061: import javax.faces.FacesException;
062: import javax.faces.component.html.HtmlPanelGrid;
063: import javax.faces.convert.IntegerConverter;
064:
065: /**
066: * <p>Page bean that corresponds to a similarly named JSP page. This
067: * class contains component definitions (and initialization code) for
068: * all components that you have defined on this page, as well as
069: * lifecycle methods and event handlers where you may add behavior
070: * to respond to incoming events.</p>
071: */
072: public class Page1 extends AbstractPageBean {
073:
074: // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
075: private int __placeholder;
076:
077: /**
078: * <p>Automatically managed component initialization. <strong>WARNING:</strong>
079: * This method is automatically generated, so any user-specified code inserted
080: * here is subject to being replaced.</p>
081: */
082: private void _init() throws Exception {
083: personDataProvider
084: .setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.personRowSet}"));
085: tripDataProvider
086: .setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{SessionBean1.tripRowSet}"));
087: }
088:
089: private Page page1 = new Page();
090:
091: public Page getPage1() {
092: return page1;
093: }
094:
095: public void setPage1(Page p) {
096: this .page1 = p;
097: }
098:
099: private Html html1 = new Html();
100:
101: public Html getHtml1() {
102: return html1;
103: }
104:
105: public void setHtml1(Html h) {
106: this .html1 = h;
107: }
108:
109: private Head head1 = new Head();
110:
111: public Head getHead1() {
112: return head1;
113: }
114:
115: public void setHead1(Head h) {
116: this .head1 = h;
117: }
118:
119: private Link link1 = new Link();
120:
121: public Link getLink1() {
122: return link1;
123: }
124:
125: public void setLink1(Link l) {
126: this .link1 = l;
127: }
128:
129: private Body body1 = new Body();
130:
131: public Body getBody1() {
132: return body1;
133: }
134:
135: public void setBody1(Body b) {
136: this .body1 = b;
137: }
138:
139: private Form form1 = new Form();
140:
141: public Form getForm1() {
142: return form1;
143: }
144:
145: public void setForm1(Form f) {
146: this .form1 = f;
147: }
148:
149: private HtmlPanelGrid mainPanel = new HtmlPanelGrid();
150:
151: public HtmlPanelGrid getMainPanel() {
152: return mainPanel;
153: }
154:
155: public void setMainPanel(HtmlPanelGrid hpg) {
156: this .mainPanel = hpg;
157: }
158:
159: private Label label1 = new Label();
160:
161: public Label getLabel1() {
162: return label1;
163: }
164:
165: public void setLabel1(Label l) {
166: this .label1 = l;
167: }
168:
169: private DropDown personId = new DropDown();
170:
171: public DropDown getPersonId() {
172: return personId;
173: }
174:
175: public void setPersonId(DropDown dd) {
176: this .personId = dd;
177: }
178:
179: private Message message1 = new Message();
180:
181: public Message getMessage1() {
182: return message1;
183: }
184:
185: public void setMessage1(Message m) {
186: this .message1 = m;
187: }
188:
189: private StaticText staticText1 = new StaticText();
190:
191: public StaticText getStaticText1() {
192: return staticText1;
193: }
194:
195: public void setStaticText1(StaticText st) {
196: this .staticText1 = st;
197: }
198:
199: private Table trips = new Table();
200:
201: public Table getTrips() {
202: return trips;
203: }
204:
205: public void setTrips(Table t) {
206: this .trips = t;
207: }
208:
209: private TableRowGroup tableRowGroup1 = new TableRowGroup();
210:
211: public TableRowGroup getTableRowGroup1() {
212: return tableRowGroup1;
213: }
214:
215: public void setTableRowGroup1(TableRowGroup trg) {
216: this .tableRowGroup1 = trg;
217: }
218:
219: private MessageGroup messageGroup1 = new MessageGroup();
220:
221: public MessageGroup getMessageGroup1() {
222: return messageGroup1;
223: }
224:
225: public void setMessageGroup1(MessageGroup mg) {
226: this .messageGroup1 = mg;
227: }
228:
229: private CachedRowSetDataProvider personDataProvider = new CachedRowSetDataProvider();
230:
231: public CachedRowSetDataProvider getPersonDataProvider() {
232: return personDataProvider;
233: }
234:
235: public void setPersonDataProvider(CachedRowSetDataProvider crsdp) {
236: this .personDataProvider = crsdp;
237: }
238:
239: private IntegerConverter personIdConverter = new IntegerConverter();
240:
241: public IntegerConverter getPersonIdConverter() {
242: return personIdConverter;
243: }
244:
245: public void setPersonIdConverter(IntegerConverter ic) {
246: this .personIdConverter = ic;
247: }
248:
249: private CachedRowSetDataProvider tripDataProvider = new CachedRowSetDataProvider();
250:
251: public CachedRowSetDataProvider getTripDataProvider() {
252: return tripDataProvider;
253: }
254:
255: public void setTripDataProvider(CachedRowSetDataProvider crsdp) {
256: this .tripDataProvider = crsdp;
257: }
258:
259: private TableColumn tableColumn1 = new TableColumn();
260:
261: public TableColumn getTableColumn1() {
262: return tableColumn1;
263: }
264:
265: public void setTableColumn1(TableColumn tc) {
266: this .tableColumn1 = tc;
267: }
268:
269: private TableColumn tableColumn3 = new TableColumn();
270:
271: public TableColumn getTableColumn3() {
272: return tableColumn3;
273: }
274:
275: public void setTableColumn3(TableColumn tc) {
276: this .tableColumn3 = tc;
277: }
278:
279: private StaticText staticText4 = new StaticText();
280:
281: public StaticText getStaticText4() {
282: return staticText4;
283: }
284:
285: public void setStaticText4(StaticText st) {
286: this .staticText4 = st;
287: }
288:
289: private TableColumn tableColumn4 = new TableColumn();
290:
291: public TableColumn getTableColumn4() {
292: return tableColumn4;
293: }
294:
295: public void setTableColumn4(TableColumn tc) {
296: this .tableColumn4 = tc;
297: }
298:
299: private StaticText staticText5 = new StaticText();
300:
301: public StaticText getStaticText5() {
302: return staticText5;
303: }
304:
305: public void setStaticText5(StaticText st) {
306: this .staticText5 = st;
307: }
308:
309: private TableColumn tableColumn5 = new TableColumn();
310:
311: public TableColumn getTableColumn5() {
312: return tableColumn5;
313: }
314:
315: public void setTableColumn5(TableColumn tc) {
316: this .tableColumn5 = tc;
317: }
318:
319: private StaticText staticText6 = new StaticText();
320:
321: public StaticText getStaticText6() {
322: return staticText6;
323: }
324:
325: public void setStaticText6(StaticText st) {
326: this .staticText6 = st;
327: }
328:
329: private TableColumn tableColumn2 = new TableColumn();
330:
331: public TableColumn getTableColumn2() {
332: return tableColumn2;
333: }
334:
335: public void setTableColumn2(TableColumn tc) {
336: this .tableColumn2 = tc;
337: }
338:
339: private StaticText staticText3 = new StaticText();
340:
341: public StaticText getStaticText3() {
342: return staticText3;
343: }
344:
345: public void setStaticText3(StaticText st) {
346: this .staticText3 = st;
347: }
348:
349: private Button button1 = new Button();
350:
351: public Button getButton1() {
352: return button1;
353: }
354:
355: public void setButton1(Button b) {
356: this .button1 = b;
357: }
358:
359: // </editor-fold>
360:
361: /**
362: * <p>Construct a new Page bean instance.</p>
363: */
364: public Page1() {
365: }
366:
367: /**
368: * <p>Callback method that is called whenever a page is navigated to,
369: * either directly via a URL, or indirectly via page navigation.
370: * Customize this method to acquire resources that will be needed
371: * for event handlers and lifecycle methods, whether or not this
372: * page is performing post back processing.</p>
373: *
374: * <p>Note that, if the current request is a postback, the property
375: * values of the components do <strong>not</strong> represent any
376: * values submitted with this request. Instead, they represent the
377: * property values that were saved for this view when it was rendered.</p>
378: */
379: public void init() {
380: // Perform initializations inherited from our superclass
381: super .init();
382: // Perform application initialization that must complete
383: // *before* managed components are initialized
384: // TODO - add your own initialiation code here
385: // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
386: // Initialize automatically managed components
387: // *Note* - this logic should NOT be modified
388: try {
389: _init();
390: } catch (Exception e) {
391: log("Page1 Initialization Failure", e);
392: throw e instanceof FacesException ? (FacesException) e
393: : new FacesException(e);
394: }
395:
396: // </editor-fold>
397: // Perform application initialization that must complete
398: // *after* managed components are initialized
399: // TODO - add your own initialization code here
400: }
401:
402: /**
403: * <p>Callback method that is called after the component tree has been
404: * restored, but before any event processing takes place. This method
405: * will <strong>only</strong> be called on a postback request that
406: * is processing a form submit. Customize this method to allocate
407: * resources that will be required in your event handlers.</p>
408: */
409: public void preprocess() {
410: }
411:
412: /**
413: * <p>Callback method that is called just before rendering takes place.
414: * This method will <strong>only</strong> be called for the page that
415: * will actually be rendered (and not, for example, on a page that
416: * handled a postback and then navigated to a different page). Customize
417: * this method to allocate resources that will be required for rendering
418: * this page.</p>
419: */
420: public void prerender() {
421: // Use this code clip in a visual web project.
422: // Place this code in the prerender() method.
423: try {
424: Integer id = (Integer) getPersonId().getSelected();
425: if (id == null) {
426: id = (Integer) getPersonDataProvider().getValue(
427: "PERSON.PERSONID");
428: }
429: getSessionBean1().getTripRowSet().setObject(1, id);
430: getTripDataProvider().refresh();
431: } catch (Exception e) {
432: throw new FacesException(e);
433: }
434: }
435:
436: /**
437: * <p>Callback method that is called after rendering is completed for
438: * this request, if <code>init()</code> was called (regardless of whether
439: * or not this was the page that was actually rendered). Customize this
440: * method to release resources acquired in the <code>init()</code>,
441: * <code>preprocess()</code>, or <code>prerender()</code> methods (or
442: * acquired during execution of an event handler).</p>
443: */
444: public void destroy() {
445: personDataProvider.close();
446: tripDataProvider.close();
447: }
448:
449: /**
450: * <p>Return a reference to the scoped data bean.</p>
451: */
452: protected SessionBean1 getSessionBean1() {
453: return (SessionBean1) getBean("SessionBean1");
454: }
455:
456: /**
457: * <p>Return a reference to the scoped data bean.</p>
458: */
459: protected RequestBean1 getRequestBean1() {
460: return (RequestBean1) getBean("RequestBean1");
461: }
462:
463: /**
464: * <p>Return a reference to the scoped data bean.</p>
465: */
466: protected ApplicationBean1 getApplicationBean1() {
467: return (ApplicationBean1) getBean("ApplicationBean1");
468: }
469:
470: public String button1_action() {
471: // TODO: Process the action. Return value is a navigation
472: this .getRequestBean1().setPersonId(
473: (Integer) this .personId.getSelected());
474: this .getRequestBean1().setTripId(
475: (Integer) this .button1.getText());
476: return "details";
477: }
478: }
|