1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.event;
25
26 import org.dbforms.config.DbFormsConfig;
27 import org.dbforms.config.FieldValue;
28 import org.dbforms.config.ResultSetVector;
29 import org.dbforms.config.Table;
30 import org.dbforms.interfaces.DbEventInterceptorData;
31
32 import org.dbforms.util.StringUtil;
33
34 import java.sql.SQLException;
35
36 import javax.servlet.http.HttpServletRequest;
37
38
39
40 /***
41 * Abstract base class for all web-events related to navigation.
42 *
43 * @author Joe Peer
44 */
45 public abstract class AbstractNavigationEvent extends AbstractWebEvent {
46 /***
47 * called by event engine
48 *
49 * @param action DOCUMENT ME!
50 * @param request DOCUMENT ME!
51 * @param config DOCUMENT ME!
52 */
53 public AbstractNavigationEvent(String action,
54 HttpServletRequest request,
55 DbFormsConfig config) {
56 super(getTableId(action), request, config);
57 }
58
59
60 /***
61 * called by DbFormsTag to create local web event
62 *
63 * @param table DOCUMENT ME!
64 * @param request DOCUMENT ME!
65 * @param config DOCUMENT ME!
66 */
67 public AbstractNavigationEvent(Table table,
68 HttpServletRequest request,
69 DbFormsConfig config) {
70 super(table.getId(), request, config);
71 }
72
73 /***
74 * Process the current event.
75 *
76 * @param filterFieldValues FieldValue array used to restrict a set of data
77 * @param orderConstraint FieldValue array used to build a cumulation of
78 * rules for ordering (sorting) and restricting fields to the actual
79 * block of data
80 * @param sqlFilter DOCUMENT ME!
81 * @param sqlFilterParams DOCUMENT ME!
82 * @param count record count
83 * @param firstPosition a string identifying the first resultset position
84 * @param lastPosition a string identifying the last resultset position
85 * @param dbConnectionName name of the used db connection. Can be used to
86 * get an own db connection, e.g. to hold it during the session (see
87 * DataSourceJDBC for example!)
88 * @param con the JDBC Connection object
89 *
90 * @return a ResultSetVector object
91 *
92 * @exception SQLException if any error occurs
93 */
94 public abstract ResultSetVector processEvent(FieldValue[] filterFieldValues,
95 FieldValue[] orderConstraint,
96 String sqlFilter,
97 FieldValue[] sqlFilterParams,
98 int count,
99 String firstPosition,
100 String lastPosition,
101 DbEventInterceptorData interceptorData)
102 throws SQLException;
103
104
105 private static int getTableId(String action) {
106 int tableId;
107
108 try {
109 tableId = StringUtil.getEmbeddedStringAsInteger(action, 2, '_');
110 } catch (Exception e) {
111 tableId = -1;
112 }
113
114 return tableId;
115 }
116 }