KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/classic/NavNextEvent.java,v 1.15 2004/10/20 10:51:30 hkollmann Exp $
3  * $Revision: 1.15 $
4  * $Date: 2004/10/20 10:51:30 $
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.classic;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 import org.dbforms.config.*;
28
29 import org.dbforms.event.*;
30
31 import java.sql.*;
32
33 import javax.servlet.http.*;
34
35
36
37 /**
38  * DOCUMENT ME!
39  *
40  * @author Joe Peer, John Peterson
41  *
42  * @deprecated This event scrolls the current ResultSet to the next row of
43  * data. <br>
44  * Provides bounded navigation.
45  */

46 public class NavNextEvent extends NavigationEvent {
47    private static Log logCat = LogFactory.getLog(NavNextEvent.class.getName()); // logging category for this class
48

49    /**
50     * Constructor.
51     *
52     * @param action the action string
53     * @param request the request object
54     * @param config the config object
55     */

56    public NavNextEvent(String JavaDoc action, HttpServletRequest request,
57       DbFormsConfig config) {
58       super(action, request, config);
59    }
60
61
62    /**
63     * Constructor used for call from localevent.
64     *
65     * @param table the Table object
66     * @param request DOCUMENT ME!
67     * @param config the config object
68     */

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

97    public ResultSetVector processEvent(FieldValue[] childFieldValues,
98       FieldValue[] orderConstraint, String JavaDoc sqlFilter,
99       FieldValue[] sqlFilterParams, int count, String JavaDoc firstPosition,
100       String JavaDoc lastPosition, DbEventInterceptorData interceptorData)
101       throws SQLException {
102       ResultSetVector rsv;
103
104       logCat.info("==>NavNextEvent");
105
106       // select in given order everyting thats greater than lastpos
107
getTable().fillWithValues(orderConstraint, lastPosition);
108       rsv = getTable().doConstrainedSelect(childFieldValues, orderConstraint,
109             sqlFilter, sqlFilterParams, Constants.COMPARE_EXCLUSIVE, count,
110             interceptorData);
111
112       if (rsv.size() == 0) {
113          logCat.info("==>NavNextLastEvent");
114          FieldValue.invert(orderConstraint);
115          rsv = getTable().doConstrainedSelect(childFieldValues,
116                orderConstraint, sqlFilter, sqlFilterParams,
117                Constants.COMPARE_NONE, count, interceptorData);
118          FieldValue.invert(orderConstraint);
119          rsv.flip();
120       }
121
122       return rsv;
123    }
124 }
125
Popular Tags