View Javadoc

1   /*
2    * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/event/AbstractNavigationEvent.java,v 1.1 2005/11/30 20:31:17 hkollmann Exp $
3    * $Revision: 1.1 $
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  
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 }