KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > event > datalist > NavNextEvent


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/datalist/NavNextEvent.java,v 1.20 2004/10/20 10:51:49 hkollmann Exp $
3  * $Revision: 1.20 $
4  * $Date: 2004/10/20 10:51:49 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.DbEventInterceptorData;
28 import org.dbforms.config.DbFormsConfig;
29 import org.dbforms.config.FieldValue;
30 import org.dbforms.config.ResultSetVector;
31 import org.dbforms.config.Table;
32
33 import org.dbforms.event.NavigationEvent;
34 import org.dbforms.event.datalist.dao.DataSourceFactory;
35 import org.dbforms.event.datalist.dao.DataSourceSessionList;
36
37 import java.sql.SQLException JavaDoc;
38
39 import javax.servlet.http.HttpServletRequest JavaDoc;
40
41
42
43 /**
44  * This event scrolls the current ResultSet to the next row of data. Provides
45  * bounded navigation. <br>
46  * Works with new factory classes
47  *
48  * @author Henner Kollmann
49  */

50 public class NavNextEvent extends NavigationEvent {
51    // logging category for this class
52
private static Log logCat = LogFactory.getLog(NavNextEvent.class.getName());
53
54    /**
55     * Constructor.
56     *
57     * @param action the action string
58     * @param request the request object
59     * @param config the config object
60     */

61    public NavNextEvent(String JavaDoc action, HttpServletRequest JavaDoc request,
62       DbFormsConfig config) {
63       super(action, request, config);
64    }
65
66
67    /**
68     * Constructor used for call from localevent.
69     *
70     * @param table the Table object
71     * @param request the request object
72     * @param config the config object
73     */

74    public NavNextEvent(Table table, HttpServletRequest JavaDoc request,
75       DbFormsConfig config) {
76       super(table, request, config);
77    }
78
79    /**
80     * Process the current event.
81     *
82     * @param filterFieldValues FieldValue array used to restrict a set of data
83     * @param orderConstraint FieldValue array used to build a cumulation of
84     * rules for ordering (sorting) and restricting fields to the actual
85     * block of data
86     * @param sqlFilter DOCUMENT ME!
87     * @param sqlFilterParams DOCUMENT ME!
88     * @param count record count
89     * @param firstPosition a string identifying the first resultset position
90     * @param lastPosition a string identifying the last resultset position
91     * @param dbConnectionName name of the used db connection. Can be used to
92     * get an own db connection, e.g. to hold it during the session (see
93     * DataSourceJDBC for example!)
94     * @param con the JDBC Connection object
95     *
96     * @return a ResultSetVector object
97     *
98     * @exception SQLException if any error occurs
99     *
100     * @todo make a option to allow original "navNew" behavior if desired
101     */

102    public ResultSetVector processEvent(FieldValue[] filterFieldValues,
103       FieldValue[] orderConstraint, String JavaDoc sqlFilter,
104       FieldValue[] sqlFilterParams, int count, String JavaDoc firstPosition,
105       String JavaDoc lastPosition, DbEventInterceptorData interceptorData)
106       throws SQLException JavaDoc {
107       logCat.info("==>NavNextEvent.processEvent");
108
109       DataSourceSessionList ds = DataSourceSessionList.getInstance(getRequest());
110       DataSourceFactory qry = ds.get(getTable(), getRequest());
111
112       if (qry == null) {
113          qry = new DataSourceFactory((String JavaDoc) interceptorData.getAttribute(
114                   DbEventInterceptorData.CONNECTIONNAME),
115                interceptorData.getConnection(), getTable());
116          qry.setSelect(filterFieldValues, orderConstraint, sqlFilter,
117             sqlFilterParams);
118          ds.put(getTable(), getRequest(), qry);
119       }
120
121       String JavaDoc position = getTable().getKeyPositionString(getTable()
122                                                                     .getFieldValues(lastPosition));
123       ResultSetVector res = qry.getNext(interceptorData, position, count);
124
125       if (ResultSetVector.isNull(res)) {
126          res = qry.getLast(interceptorData, count);
127       }
128
129       return res;
130    }
131 }
132
Popular Tags