KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > sqltable > SqlTable


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.sqltable;
14
15 import javax.servlet.http.HttpSessionBindingEvent JavaDoc;
16 import javax.servlet.http.HttpSessionBindingListener JavaDoc;
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 /**
24  * @author av
25  * @since Oct 6, 2004
26  */

27 public class SqlTable implements HttpSessionBindingListener JavaDoc {
28   String JavaDoc orderBy;
29   String JavaDoc nestedOrderBy;
30   boolean descending;
31   String JavaDoc id;
32   int maxRows = -1; // -1 means all
33
int startRow = 0; // first row is 0
34
Dispatcher dispatcher = new DispatcherSupport();
35   int counter;
36
37   public String JavaDoc getId() {
38     return id;
39   }
40
41   public void setId(String JavaDoc 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 JavaDoc getOrderBy() {
54     return orderBy;
55   }
56
57   public void setOrderBy(String JavaDoc 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 JavaDoc ev) {
78     Controller.instance(ev.getSession()).addRequestListener(dispatcher);
79   }
80
81   public void valueUnbound(HttpSessionBindingEvent JavaDoc ev) {
82     dispatcher.clear();
83   }
84
85   public void addRequestListener(String JavaDoc name, String JavaDoc 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 JavaDoc nextId() {
95     counter += 1;
96     return id + "." + counter;
97   }
98
99   public String JavaDoc toString() {
100     return "SqlTable[id=" + id + ", orderBy=" + orderBy + ", descending=" + descending
101         + ", maxRows=" + maxRows + ", startRow=" + startRow + "]";
102   }
103   public String JavaDoc getNestedOrderBy() {
104     return nestedOrderBy;
105   }
106   public void setNestedOrderBy(String JavaDoc nestedOrderBy) {
107     this.nestedOrderBy = nestedOrderBy;
108   }
109 }
110
Popular Tags