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