View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/classic/NavNextEvent.java,v 1.17 2005/11/30 20:31:17 hkollmann Exp $
3    * $Revision: 1.17 $
4    * $Date: 2005/11/30 20:31:17 $
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  import org.dbforms.interfaces.DbEventInterceptorData;
31  
32  import java.sql.*;
33  
34  import javax.servlet.http.*;
35  
36  
37  
38  /***
39   * DOCUMENT ME!
40   *
41   * @author Joe Peer, John Peterson
42   *
43   * @deprecated This event scrolls the current ResultSet to the next row of
44   *             data. <br>
45   *             Provides bounded navigation.
46   */
47  public class NavNextEvent extends AbstractNavigationEvent {
48     private static Log logCat = LogFactory.getLog(NavNextEvent.class.getName()); // logging category for this class
49  
50     /***
51      * Constructor.
52      *
53      * @param action the action string
54      * @param request the request object
55      * @param config the config object
56      */
57     public NavNextEvent(String action, HttpServletRequest request,
58        DbFormsConfig config) {
59        super(action, request, config);
60     }
61  
62  
63     /***
64      * Constructor used for call from localevent.
65      *
66      * @param table the Table object
67      * @param request DOCUMENT ME!
68      * @param config the config object
69      */
70     public NavNextEvent(Table table, HttpServletRequest request,
71        DbFormsConfig config) {
72        super(table, request, config);
73     }
74  
75     /***
76      * Process the current event.
77      *
78      * @param childFieldValues FieldValue array used to restrict a set of data
79      * @param orderConstraint FieldValue array used to build a cumulation of
80      *        rules for ordering (sorting) and restricting fields to the actual
81      *        block of data
82      * @param firstPosition DOCUMENT ME!
83      * @param sqlFilterParams a string identifying the last resultset position
84      * @param count record count
85      * @param firstPosition a string identifying the first resultset position
86      * @param lastPosition DOCUMENT ME!
87      * @param dbConnectionName name of the used db connection. Can be used to
88      *        get an own db connection, e.g. to hold it during the session (see
89      *        DataSourceJDBC for example!)
90      * @param con the JDBC Connection object
91      *
92      * @return a ResultSetVector object
93      *
94      * @exception SQLException if any error occurs
95      *
96      * @todo make a option to allow original "navNew" behavior if desired
97      */
98     public ResultSetVector processEvent(FieldValue[] childFieldValues,
99        FieldValue[] orderConstraint, String sqlFilter,
100       FieldValue[] sqlFilterParams, int count, String firstPosition,
101       String lastPosition, DbEventInterceptorData interceptorData)
102       throws SQLException {
103       ResultSetVector rsv;
104 
105       logCat.info("==>NavNextEvent");
106 
107       // select in given order everyting thats greater than lastpos
108       getTable().fillWithValues(orderConstraint, lastPosition);
109       rsv = getTable().doConstrainedSelect(childFieldValues, orderConstraint,
110             sqlFilter, sqlFilterParams, Constants.COMPARE_EXCLUSIVE, count,
111             interceptorData);
112 
113       if (rsv.size() == 0) {
114          logCat.info("==>NavNextLastEvent");
115          FieldValue.invert(orderConstraint);
116          rsv = getTable().doConstrainedSelect(childFieldValues,
117                orderConstraint, sqlFilter, sqlFilterParams,
118                Constants.COMPARE_NONE, count, interceptorData);
119          FieldValue.invert(orderConstraint);
120          rsv.flip();
121       }
122 
123       return rsv;
124    }
125 }