1 13 package com.tonbeller.wcf.sqltable; 14 15 import javax.servlet.http.HttpSessionBindingEvent ; 16 import javax.servlet.http.HttpSessionBindingListener ; 17 18 import com.tonbeller.wcf.controller.Controller; 19 import com.tonbeller.wcf.controller.Dispatcher; 20 import com.tonbeller.wcf.controller.DispatcherSupport; 21 import com.tonbeller.wcf.controller.RequestListener; 22 23 27 public class SqlTable implements HttpSessionBindingListener { 28 String orderBy; 29 String nestedOrderBy; 30 boolean descending; 31 String id; 32 int maxRows = -1; int startRow = 0; Dispatcher dispatcher = new DispatcherSupport(); 35 int counter; 36 37 public String getId() { 38 return id; 39 } 40 41 public void setId(String id) { 42 this.id = id; 43 } 44 45 public boolean isDescending() { 46 return descending; 47 } 48 49 public void setDescending(boolean descending) { 50 this.descending = descending; 51 } 52 53 public String getOrderBy() { 54 return orderBy; 55 } 56 57 public void setOrderBy(String orderBy) { 58 this.orderBy = orderBy; 59 } 60 61 public int getMaxRows() { 62 return maxRows; 63 } 64 65 public void setMaxRows(int maxRows) { 66 this.maxRows = maxRows; 67 } 68 69 public int getStartRow() { 70 return startRow; 71 } 72 73 public void setStartRow(int startRow) { 74 this.startRow = startRow; 75 } 76 77 public void valueBound(HttpSessionBindingEvent ev) { 78 Controller.instance(ev.getSession()).addRequestListener(dispatcher); 79 } 80 81 public void valueUnbound(HttpSessionBindingEvent ev) { 82 dispatcher.clear(); 83 } 84 85 public void addRequestListener(String name, String value, RequestListener rl) { 86 dispatcher.addRequestListener(name, value, rl); 87 } 88 89 public void clear() { 90 dispatcher.clear(); 91 counter = 0; 92 } 93 94 public String nextId() { 95 counter += 1; 96 return id + "." + counter; 97 } 98 99 public String toString() { 100 return "SqlTable[id=" + id + ", orderBy=" + orderBy + ", descending=" + descending 101 + ", maxRows=" + maxRows + ", startRow=" + startRow + "]"; 102 } 103 public String getNestedOrderBy() { 104 return nestedOrderBy; 105 } 106 public void setNestedOrderBy(String nestedOrderBy) { 107 this.nestedOrderBy = nestedOrderBy; 108 } 109 } 110 | Popular Tags |