KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > taglib > DbFormTagTEI


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbFormTagTEI.java,v 1.14 2004/08/18 12:26:07 hkollmann Exp $
3  * $Revision: 1.14 $
4  * $Date: 2004/08/18 12:26:07 $
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.taglib;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import org.dbforms.util.Util;
30
31 import javax.servlet.jsp.tagext.*;
32
33
34
35 /**
36  * DOCUMENT ME!
37  *
38  * @author $author$
39  * @version $Revision: 1.14 $
40  */

41 public class DbFormTagTEI extends TagExtraInfo {
42    // logging category for this class
43
static Log logCat = LogFactory.getLog(DbFormTagTEI.class.getName());
44
45    /**
46     * DOCUMENT ME!
47     *
48     * @param data DOCUMENT ME!
49     *
50     * @return DOCUMENT ME!
51     */

52    public VariableInfo[] getVariableInfo(TagData data) {
53       StringBuffer JavaDoc[] varNames = {
54                                    new StringBuffer JavaDoc("currentRow"),
55                                    new StringBuffer JavaDoc("position"),
56                                    new StringBuffer JavaDoc("searchFieldNames"),
57                                    new StringBuffer JavaDoc("searchFieldModeNames"),
58                                    new StringBuffer JavaDoc("searchFieldAlgorithmNames"),
59                                    new StringBuffer JavaDoc("rsv")
60                                 };
61
62       // convention for DbFroms TEI-provided variables: varName "_" tableName
63
// this is necessary to prevent JSP compiler errors if forms are nested
64
String JavaDoc table = null;
65
66       try {
67          table = data.getAttributeString("tableName");
68       } catch (Exception JavaDoc e) {
69          table = null;
70       }
71
72       String JavaDoc parentField = null;
73
74       try {
75          parentField = data.getAttributeString("parentField");
76       } catch (Exception JavaDoc e) {
77          parentField = null;
78       }
79
80       String JavaDoc childField = null;
81
82       try {
83          childField = data.getAttributeString("childField");
84       } catch (Exception JavaDoc e) {
85          childField = null;
86       }
87
88       if (table != null) {
89          for (int i = 0; i < varNames.length; i++) {
90             varNames[i].append("_");
91             varNames[i].append(table.replace('.', '_')); // # jp 27-06-2001
92
}
93       }
94
95       logCat.info("*** TEI CLASS IN ACTION ***");
96       logCat.info("table=" + table);
97       logCat.info("varNames[0]=" + varNames[0].toString());
98
99       int count = 0;
100
101       if (!Util.isNull(table)) {
102          count = count + 6;
103       }
104
105       if (Util.isNull(parentField) && Util.isNull(childField)) {
106          count = count + 1;
107       }
108
109       VariableInfo[] info = null;
110
111       if (count > 0) {
112          info = new VariableInfo[count];
113
114          int i = 0;
115
116          if (!Util.isNull(table)) {
117             info[i++] = new VariableInfo(varNames[0].toString(),
118                                          "java.util.Map", true,
119                                          VariableInfo.NESTED);
120             info[i++] = new VariableInfo(varNames[1].toString(),
121                                          "java.lang.String", true,
122                                          VariableInfo.NESTED);
123             info[i++] = new VariableInfo(varNames[2].toString(),
124                                          "java.util.Map", true,
125                                          VariableInfo.NESTED);
126             info[i++] = new VariableInfo(varNames[3].toString(),
127                                          "java.util.Map", true,
128                                          VariableInfo.NESTED);
129             info[i++] = new VariableInfo(varNames[4].toString(),
130                                          "java.util.Map", true,
131                                          VariableInfo.NESTED);
132             info[i++] = new VariableInfo(varNames[5].toString(),
133                                          "org.dbforms.config.ResultSetVector",
134                                          true, VariableInfo.NESTED);
135          }
136
137          if (Util.isNull(parentField) && Util.isNull(childField)) {
138             info[i++] = new VariableInfo("dbforms", "java.util.Map", true,
139                                          VariableInfo.NESTED);
140          }
141       }
142
143       return info;
144    }
145 }
146
Popular Tags