1:/* 2: * RoomReservations.java 3: * 4: * Created on December 10, 2005, 7:08 PM 5: * Copyright Mike 6: */ 7:package webreservations; 8: 9:import javax.faces.context.FacesContext; 10:import com.sun.web.ui.appbase.AbstractPageBean; 11:import com.sun.web.ui.component.Body; 12:import com.sun.web.ui.component.Form; 13:import com.sun.web.ui.component.Head; 14:import com.sun.web.ui.component.Html; 15:import com.sun.web.ui.component.Link; 16:import com.sun.web.ui.component.Page; 17:import javax.faces.FacesException; 18:import com.sun.web.ui.component.Table; 19:import com.sun.web.ui.component.StaticText; 20:import com.sun.web.ui.component.TableRowGroup; 21:import com.sun.web.ui.model.DefaultTableDataProvider; 22:import com.sun.web.ui.component.TableColumn; 23:import com.sun.data.provider.RowKey; 24:import com.sun.data.provider.impl.CachedRowSetDataProvider; 25:import com.sun.web.ui.component.TextField; 26:import com.sun.web.ui.component.Label; 27:import com.sun.web.ui.component.Button; 28: 29:/** 30: * <p>Page bean that corresponds to a similarly named JSP page. This 31: * class contains component definitions (and initialization code) for 32: * all components that you have defined on this page, as well as 33: * lifecycle methods and event handlers where you may add behavior 34: * to respond to incoming events.</p> 35: */ 36:public class RoomReservations extends AbstractPageBean { 37: // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition"> 38: private int __placeholder; 39: 40: private Page page1 = new Page(); 41: 42: public Page getPage1() { 43: return page1; 44: } 45: 46: public void setPage1(Page p) { 47: this.page1 = p; 48: } 49: 50: private Html html1 = new Html(); 51: 52: public Html getHtml1() { 53: return html1; 54: } 55: 56: public void setHtml1(Html h) { 57: this.html1 = h; 58: } 59: 60: private Head head1 = new Head(); 61: 62: public Head getHead1() { 63: return head1; 64: } 65: 66: public void setHead1(Head h) { 67: this.head1 = h; 68: } 69: 70: private Link link1 = new Link(); 71: 72: public Link getLink1() { 73: return link1; 74: } 75: 76: public void setLink1(Link l) { 77: this.link1 = l; 78: } 79: 80: private Body body1 = new Body(); 81: 82: public Body getBody1() { 83: return body1; 84: } 85: 86: public void setBody1(Body b) { 87: this.body1 = b; 88: } 89: 90: private Form form1 = new Form(); 91: 92: public Form getForm1() { 93: return form1; 94: } 95: 96: public void setForm1(Form f) { 97: this.form1 = f; 98: } 99: 100: private Table tblReservations = new Table(); 101: 102: public Table getTblReservations() { 103: return tblReservations; 104: } 105: 106: public void setTblReservations(Table t) { 107: this.tblReservations = t; 108: } 109: 110: private StaticText tblReservationsTitle = new StaticText(); 111: 112: public StaticText getTblReservationsTitle() { 113: return tblReservationsTitle; 114: } 115: 116: public void setTblReservationsTitle(StaticText st) { 117: this.tblReservationsTitle = st; 118: } 119: 120: private TableRowGroup tblRowGroupReservations = new TableRowGroup(); 121: 122: public TableRowGroup getTblRowGroupReservations() { 123: return tblRowGroupReservations; 124: } 125: 126: public void setTblRowGroupReservations(TableRowGroup trg) { 127: this.tblRowGroupReservations = trg; 128: } 129: 130: private CachedRowSetDataProvider room_reservationsDataProvider = new CachedRowSetDataProvider(); 131: 132: public CachedRowSetDataProvider getRoom_reservationsDataProvider() { 133: return room_reservationsDataProvider; 134: } 135: 136: public void setRoom_reservationsDataProvider(CachedRowSetDataProvider crsdp) { 137: this.room_reservationsDataProvider = crsdp; 138: } 139: private Label lblReservationsTitle = new Label(); 140: 141: public Label getLblReservationsTitle() { 142: return lblReservationsTitle; 143: } 144: 145: public void setLblReservationsTitle(Label l) { 146: this.lblReservationsTitle = l; 147: } 148: 149: private TableColumn tableColumn1 = new TableColumn(); 150: 151: public TableColumn getTableColumn1() { 152: return tableColumn1; 153: } 154: 155: public void setTableColumn1(TableColumn tc) { 156: this.tableColumn1 = tc; 157: } 158: 159: private StaticText staticText1 = new StaticText(); 160: 161: public StaticText getStaticText1() { 162: return staticText1; 163: } 164: 165: public void setStaticText1(StaticText st) { 166: this.staticText1 = st; 167: } 168: 169: private TableColumn tableColumn2 = new TableColumn(); 170: 171: public TableColumn getTableColumn2() { 172: return tableColumn2; 173: } 174: 175: public void setTableColumn2(TableColumn tc) { 176: this.tableColumn2 = tc; 177: } 178: 179: private StaticText staticText2 = new StaticText(); 180: 181: public StaticText getStaticText2() { 182: return staticText2; 183: } 184: 185: public void setStaticText2(StaticText st) { 186: this.staticText2 = st; 187: } 188: 189: private TableColumn tableColumn3 = new TableColumn(); 190: 191: public TableColumn getTableColumn3() { 192: return tableColumn3; 193: } 194: 195: public void setTableColumn3(TableColumn tc) { 196: this.tableColumn3 = tc; 197: } 198: 199: private StaticText staticText3 = new StaticText(); 200: 201: public StaticText getStaticText3() { 202: return staticText3; 203: } 204: 205: public void setStaticText3(StaticText st) { 206: this.staticText3 = st; 207: } 208: 209: private TableColumn tableColumn4 = new TableColumn(); 210: 211: public TableColumn getTableColumn4() { 212: return tableColumn4; 213: } 214: 215: public void setTableColumn4(TableColumn tc) { 216: this.tableColumn4 = tc; 217: } 218: 219: private StaticText staticText4 = new StaticText(); 220: 221: public StaticText getStaticText4() { 222: return staticText4; 223: } 224: 225: public void setStaticText4(StaticText st) { 226: this.staticText4 = st; 227: } 228: 229: private TableColumn tableColumn5 = new TableColumn(); 230: 231: public TableColumn getTableColumn5() { 232: return tableColumn5; 233: } 234: 235: public void setTableColumn5(TableColumn tc) { 236: this.tableColumn5 = tc; 237: } 238: 239: private Button btnDeleteReservation = new Button(); 240: 241: public Button getBtnDeleteReservation() { 242: return btnDeleteReservation; 243: } 244: 245: public void setBtnDeleteReservation(Button b) { 246: this.btnDeleteReservation = b; 247: } 248: 249: private Button btnMakeNewReservation = new Button(); 250: 251: public Button getBtnMakeNewReservation() { 252: return btnMakeNewReservation; 253: } 254: 255: public void setBtnMakeNewReservation(Button b) { 256: this.btnMakeNewReservation = b; 257: } 258: 259: // </editor-fold> 260: 261: 262: /** 263: * <p>Construct a new Page bean instance.</p> 264: */ 265: public RoomReservations() { 266: // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization"> 267: try { 268: room_reservationsDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet)getValue("#{ReservationsSessionBean.room_reservationsRowSet}")); 269: } catch (Exception e) { 270: log("RoomReservations Initialization Failure", e); 271: throw e instanceof FacesException ? (FacesException) e: new FacesException(e); 272: } 273: // </editor-fold> 274: // TODO: Add your own initialization code here (optional) 275: try { 276: System.out.println("Creating RoomReservations instance..."); 277: ReservationsSessionBean resBean = 278: (ReservationsSessionBean)this.getBean("ReservationsSessionBean"); 279: 280: //Set appropriate heading according to conference room name: 281: this.lblReservationsTitle.setValue("Current Room Reservations for " + 282: resBean.getRoomName()); 283: 284: //Load only those reservations for selected room_id: 285: resBean.getRoom_reservationsRowSet().setObject(1,resBean.getRoomId()); 286: //getSessionBean1().getTripRowSet().setObject(1,personDD.getSelected()); 287: //this.tblReservations. 288: this.room_reservationsDataProvider.refresh(); 289: //this.tblReservations. 290: } catch (Exception e){ 291: System.out.println("Error occurred creating reservations page : " + e); 292: } 293: // this.txtId.setText(((ReservationsSessionBean)this.getBean("ReservationsSessionBean")).getRoomId()); 294: //look at comment above, if id there, filter table. offer edit/add new link 295: } 296: 297: /** 298: * <p>Return a reference to the scoped data bean.</p> 299: */ 300: protected ReservationsSessionBean getReservationsSessionBean() { 301: return (ReservationsSessionBean)getBean("ReservationsSessionBean"); 302: } 303: 304: 305: /** 306: * <p>Callback method that is called whenever a page is navigated to, 307: * either directly via a URL, or indirectly via page navigation. 308: * Customize this method to acquire resources that will be needed 309: * for event handlers and lifecycle methods, whether or not this 310: * page is performing post back processing.</p> 311: * 312: * <p>Note that, if the current request is a postback, the property 313: * values of the components do <strong>not</strong> represent any 314: * values submitted with this request. Instead, they represent the 315: * property values that were saved for this view when it was rendered.</p> 316: */ 317: public void init() { 318: } 319: 320: /** 321: * <p>Callback method that is called after the component tree has been 322: * restored, but before any event processing takes place. This method 323: * will <strong>only</strong> be called on a postback request that 324: * is processing a form submit. Customize this method to allocate 325: * resources that will be required in your event handlers.</p> 326: */ 327: public void preprocess() { 328: } 329: 330: /** 331: * <p>Callback method that is called just before rendering takes place. 332: * This method will <strong>only</strong> be called for the page that 333: * will actually be rendered (and not, for example, on a page that 334: * handled a postback and then navigated to a different page). Customize 335: * this method to allocate resources that will be required for rendering 336: * this page.</p> 337: */ 338: public void prerender() { 339: } 340: 341: 342: /** 343: * <p>Callback method that is called after rendering is completed for 344: * this request, if <code>init()</code> was called (regardless of whether 345: * or not this was the page that was actually rendered). Customize this 346: * method to release resources acquired in the <code>init()</code>, 347: * <code>preprocess()</code>, or <code>prerender()</code> methods (or 348: * acquired during execution of an event handler).</p> 349: */ 350: public void destroy() { 351: room_reservationsDataProvider.close();