KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > webman > field > TKFormTypeSelectorField


1 package com.teamkonzept.webman.field;
2
3 import com.teamkonzept.webman.mainint.*;
4 import com.teamkonzept.webman.mainint.db.queries.TKDBContentTreeGetType;
5 import com.teamkonzept.webman.mainint.db.queries.*;
6 import de.webman.content.eventhandler.CEUtils;
7
8 import com.teamkonzept.lib.*;
9 import com.teamkonzept.publishing.markups.*;
10 import com.teamkonzept.web.*;
11 import com.teamkonzept.field.db.*;
12 import com.teamkonzept.field.db.queries.*;
13 import com.teamkonzept.db.*;
14 import com.teamkonzept.field.*;
15 import com.teamkonzept.international.LanguageManager;
16 import de.webman.generator.*;
17 import java.sql.*;
18 import java.util.*;
19 import org.apache.log4j.Category;
20
21 /**
22  * The form type selector field control.
23  *
24  * @author $Author: uli $
25  * @version $Revision: 1.11 $
26  */

27 public class TKFormTypeSelectorField
28     extends TKSelectField
29 {
30     /**
31      * The class identifier.
32      */

33     public static final String JavaDoc CLASS_ID = "FORMLIST";
34
35     /**
36      * The logging category.
37      */

38     private static Category cat = Category.getInstance(TKFormTypeSelectorField.class);
39
40     /**
41      * The <CODE>structure</CODE> form type constant.
42      */

43     public static final Integer JavaDoc STRUCTURE_FORM_TYPE = new Integer JavaDoc(1);
44
45     /**
46      * The <CODE>fragment</CODE> form type constant.
47      */

48     public static final Integer JavaDoc FRAGMENT_FORM_TYPE = new Integer JavaDoc(2);
49
50     /**
51      * The <CODE>content</CODE> form type constant.
52      */

53     public static final Integer JavaDoc CONTENT_FORM_TYPE = new Integer JavaDoc(3);
54
55     /**
56      * The selected form type.
57      */

58     protected Integer JavaDoc formType = null;
59
60     /**
61      * Creates an empty form type selector field control.
62      */

63     public TKFormTypeSelectorField ()
64     {
65         super();
66     }
67
68     public TKFormTypeSelectorField(
69         String JavaDoc name,
70         String JavaDoc showName,
71         Integer JavaDoc fType
72     )
73     {
74         initSelectorField( CLASS_ID, name, showName, fType );
75     }
76
77     public void initSelectorField(
78         String JavaDoc type,
79         String JavaDoc name,
80         String JavaDoc showName,
81         Integer JavaDoc fType
82     )
83     {
84         initSelectField( type, name, showName, new TKVector(), 1, false );
85         formType = fType;
86     }
87
88     public void fillIntoTemplate( TKHTMLTemplate t, Object JavaDoc value, String JavaDoc prefix )
89     {
90         TKVector tmpOptionList = optionList;
91         try {
92             // Achtung hier noch den Formtype !!!!
93
TKQuery q = TKDBManager.newQuery( TKDBFormGetAll69.class );
94             // q.setQueryParams( "FORM_TYPE", fNodeType );
95
q.execute();
96             ResultSet res = q.fetchResultSet();
97             TKVector newOptionList = new TKVector();
98             newOptionList.addElement(new TKOptionFieldEntry(LanguageManager.getText("form", "OPTIONLIST_POSSIBILITIES"), "0"));
99             while( res.next() ) {
100                 String JavaDoc name = res.getString("FORM_NAME");
101                 newOptionList.addElement(
102                     new TKOptionFieldEntry(
103                         name,
104                         String.valueOf( res.getInt("FORM_ID") )
105                     )
106                 );
107             }
108             res.close();
109             optionList = newOptionList;
110         }
111         catch( SQLException e ) {
112             cat.error("fillIntoTemplate", e);
113             return;
114         }
115         super.fillIntoTemplate( t, value, prefix );
116         optionList = tmpOptionList;
117     }
118
119     /**
120      * Checks wether this object and the specified object
121      * may be treated as equal.
122      *
123      * @param object the object to checked for equality.
124      * @return <CODE>true</CODE> if this object and the
125      * specified object may be treated as equal, otherwise
126      * <CODE>false</CODE>.
127      */

128     public boolean equals (Object JavaDoc object)
129     {
130         if (! super.equals(object))
131         {
132             return false;
133         }
134
135         TKFormTypeSelectorField field = (TKFormTypeSelectorField) object;
136
137         return (this.formType == null ? field.formType == null : this.formType.equals(field.formType));
138     }
139
140     /**
141      * Returns the hash code for this object.
142      *
143      * @return the hash code for this object.
144      */

145     public int hashCode ()
146     {
147         // Implementation for JTest only ;-(
148
return super.hashCode();
149     }
150
151 }
152
Popular Tags