KickJava   Java API By Example, From Geeks To Geeks.

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


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 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
29     extends TKSelectField
30 {
31     // $Id: TKDocumentTypeSelectorField.java,v 1.8 2002/02/19 14:08:16 gregor Exp $
32

33     /**
34      * The class identifier of this field class.
35      */

36     public static final String JavaDoc CLASS_ID = "DOC_TYPE_LIST";
37
38     /**
39      * logging category
40      */

41     private static final Category CATEGORY = Category.getInstance(TKDocumentTypeSelectorField.class);
42
43     /**
44      * default constructor
45      */

46     public TKDocumentTypeSelectorField() {};
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 JavaDoc name, String JavaDoc showName)
54     {
55         initSelectorField( CLASS_ID, name, showName);
56     }
57
58     public void initSelectorField(
59         String JavaDoc type,
60         String JavaDoc name,
61         String JavaDoc showName
62     )
63     {
64         initSelectField( type, name, showName, new TKVector(), 1, false );
65     }
66
67     public void fillIntoTemplate( TKHTMLTemplate t, Object JavaDoc value, String JavaDoc prefix )
68     {
69         TKVector tmpOptionList = optionList;
70         try {
71             TKQuery q = TKDBManager.newQuery( TKDBPresentationGet.class );
72             q.execute();
73             ResultSet res = q.fetchResultSet();
74             TKVector newOptionList = new TKVector();
75
76             // the value of the possibilies default must be -1, since
77
// document types start counting with "0" --gck
78
newOptionList.addElement(new TKOptionFieldEntry(LanguageManager.getText("form",
79                                                                                     "OPTIONLIST_POSSIBILITIES"),
80                                                             "-1"));
81
82             while( res.next() ) {
83                 String JavaDoc name = res.getString("PRESENTATION_NAME");
84                 newOptionList.addElement(
85                     new TKOptionFieldEntry(
86                         name,
87                         String.valueOf( res.getInt("PRESENTATION_ID") )
88                     )
89                 );
90             }
91
92             res.close();
93             optionList = newOptionList;
94         }
95         catch( SQLException e ) {
96             CATEGORY.error("fillIntoTemplate: " ,e);
97             return;
98         }
99         super.fillIntoTemplate( t, value, prefix );
100         optionList = tmpOptionList;
101     }
102
103 }
104
Popular Tags