01: package com.teamkonzept.webman.field;
02:
03: import com.teamkonzept.webman.mainint.*;
04: import com.teamkonzept.webman.mainint.db.queries.TKDBContentTreeGetType;
05: import com.teamkonzept.webman.mainint.db.queries.*;
06: import de.webman.content.eventhandler.CEUtils;
07:
08: import com.teamkonzept.lib.*;
09: 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 de.webman.generator.*;
16: import com.teamkonzept.international.LanguageManager;
17:
18: import java.sql.*;
19: import java.util.*;
20: import org.apache.log4j.Category;
21:
22: /**
23: * The document type selector.
24: *
25: * @author $Author: gregor $
26: * @version $Revision: 1.8 $
27: */
28: public class TKDocumentTypeSelectorField extends TKSelectField {
29: // $Id: TKDocumentTypeSelectorField.java,v 1.8 2002/02/19 14:08:16 gregor Exp $
30:
31: /**
32: * The class identifier of this field class.
33: */
34: public static final String CLASS_ID = "DOC_TYPE_LIST";
35:
36: /**
37: * logging category
38: */
39: private static final Category CATEGORY = Category
40: .getInstance(TKDocumentTypeSelectorField.class);
41:
42: /**
43: * default constructor
44: */
45: public TKDocumentTypeSelectorField() {
46: };
47:
48: /**
49: * constructor
50: * @param name the field object's id
51: * @param showName the field object's name
52: */
53: public TKDocumentTypeSelectorField(String name, String showName) {
54: initSelectorField(CLASS_ID, name, showName);
55: }
56:
57: public void initSelectorField(String type, String name,
58: String showName) {
59: initSelectField(type, name, showName, new TKVector(), 1, false);
60: }
61:
62: public void fillIntoTemplate(TKHTMLTemplate t, Object value,
63: String prefix) {
64: TKVector tmpOptionList = optionList;
65: try {
66: TKQuery q = TKDBManager.newQuery(TKDBPresentationGet.class);
67: q.execute();
68: ResultSet res = q.fetchResultSet();
69: TKVector newOptionList = new TKVector();
70:
71: // the value of the possibilies default must be -1, since
72: // document types start counting with "0" --gck
73: newOptionList.addElement(new TKOptionFieldEntry(
74: LanguageManager.getText("form",
75: "OPTIONLIST_POSSIBILITIES"), "-1"));
76:
77: while (res.next()) {
78: String name = res.getString("PRESENTATION_NAME");
79: newOptionList.addElement(new TKOptionFieldEntry(name,
80: String.valueOf(res.getInt("PRESENTATION_ID"))));
81: }
82:
83: res.close();
84: optionList = newOptionList;
85: } catch (SQLException e) {
86: CATEGORY.error("fillIntoTemplate: ", e);
87: return;
88: }
89: super.fillIntoTemplate(t, value, prefix);
90: optionList = tmpOptionList;
91: }
92:
93: }
|