1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.dbforms.event.datalist;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 import org.dbforms.config.DbFormsConfig;
28 import org.dbforms.config.FieldValue;
29 import org.dbforms.config.ResultSetVector;
30 import org.dbforms.config.Table;
31
32 import org.dbforms.event.AbstractNavigationEvent;
33 import org.dbforms.event.datalist.dao.DataSourceFactory;
34 import org.dbforms.event.datalist.dao.DataSourceSessionList;
35 import org.dbforms.interfaces.DbEventInterceptorData;
36
37 import java.sql.SQLException;
38
39 import javax.servlet.http.HttpServletRequest;
40
41
42
43 /***
44 * This event scrolls the current ResultSet to its last row of data. <br>
45 * Works with new factory classes
46 *
47 * @author Henner Kollmann
48 */
49 public class NavLastEvent extends AbstractNavigationEvent {
50
51 private static Log logCat = LogFactory.getLog(NavLastEvent.class.getName());
52
53 /***
54 * Creates a new NavLastEvent object.
55 *
56 * @param action the action string
57 * @param request the request object
58 * @param config the config object
59 */
60 public NavLastEvent(String action, HttpServletRequest request,
61 DbFormsConfig config) {
62 super(action, request, config);
63 }
64
65
66 /***
67 * Creates a new NavLastEvent object.
68 *
69 * @param table the input table object
70 * @param request the request object
71 * @param config the config object
72 */
73 public NavLastEvent(Table table, HttpServletRequest request,
74 DbFormsConfig config) {
75 super(table, request, config);
76 }
77
78 /***
79 * Process the current event.
80 *
81 * @param filterFieldValues FieldValue array used to restrict a set of data
82 * @param orderConstraint FieldValue array used to build a cumulation of
83 * rules for ordering (sorting) and restricting fields to the actual
84 * block of data
85 * @param sqlFilter DOCUMENT ME!
86 * @param sqlFilterParams DOCUMENT ME!
87 * @param count record count
88 * @param firstPosition a string identifying the first resultset position
89 * @param lastPosition a string identifying the last resultset position
90 * @param dbConnectionName name of the used db connection. Can be used to
91 * get an own db connection, e.g. to hold it during the session (see
92 * DataSourceJDBC for example!)
93 * @param con the JDBC Connection object
94 *
95 * @return a ResultSetVector object
96 *
97 * @exception SQLException if any error occurs
98 */
99 public ResultSetVector processEvent(FieldValue[] filterFieldValues,
100 FieldValue[] orderConstraint, String sqlFilter,
101 FieldValue[] sqlFilterParams, int count, String firstPosition,
102 String lastPosition, DbEventInterceptorData interceptorData)
103 throws SQLException {
104 logCat.info("==>NavLastEvent.processEvent");
105
106 DataSourceSessionList ds = DataSourceSessionList.getInstance(getRequest());
107 DataSourceFactory qry = null;
108 boolean force = getRequest().getAttribute("forceUpdate") != null;
109 if (force) {
110 ds.remove(getTable(), getRequest());
111 } else {
112 qry = ds.get(getTable(), getRequest());
113 }
114
115 if (qry == null) {
116 qry = new DataSourceFactory((String) interceptorData.getAttribute(
117 DbEventInterceptorData.CONNECTIONNAME),
118 interceptorData.getConnection(), getTable());
119 qry.setSelect(filterFieldValues, orderConstraint, sqlFilter,
120 sqlFilterParams);
121 ds.put(getTable(), getRequest(), qry);
122 }
123
124 return qry.getLast(interceptorData, count);
125 }
126 }