1 package com.teamkonzept.webman.field; 2 3 import com.teamkonzept.webman.mainint.*; 4 import com.teamkonzept.webman.mainint.db.queries.TKDBContentTreeGetTypeOrderByName; 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 17 import java.sql.*; 18 import java.util.*; 19 20 26 public class TKContentNodeTypeSelectorField 27 extends TKSelectField 28 { 29 31 34 public static final String CLASS_ID = "GROUPNODELIST"; 35 36 39 public static final Integer DIRECTORY_NODE_TYPE = new Integer (1); 40 41 44 public static final Integer GROUP_NODE_TYPE = new Integer (2); 45 46 49 public static final Integer SINGLE_NODE_TYPE = new Integer (3); 50 51 54 protected Integer fNodeType = null; 55 56 59 public TKContentNodeTypeSelectorField () 60 { 61 super(); 62 } 63 64 public TKContentNodeTypeSelectorField( 65 String name, 66 String showName, 67 Integer nodeType 68 ) 69 { 70 initContentNodeTypeSelectorField( CLASS_ID, name, showName, nodeType ); 71 } 72 73 public void initContentNodeTypeSelectorField( 74 String type, 75 String name, 76 String showName, 77 Integer nodeType 78 ) 79 { 80 initSelectField( type, name, showName, new TKVector(), 1, false ); 81 fNodeType = nodeType; 82 } 83 84 public void fillIntoTemplate( TKHTMLTemplate t, Object value, String prefix ) 85 { 86 TKVector tmpOptionList = optionList; 87 try { 88 TKQuery q = TKDBManager.newQuery( TKDBContentTreeGetTypeOrderByName.class ); 89 q.setQueryParams( "CONTENT_NODE_TYPE", fNodeType ); 90 q.execute(); 91 ResultSet res = q.fetchResultSet(); 92 TKVector newOptionList = new TKVector(); 93 newOptionList.addElement(new TKOptionFieldEntry(LanguageManager.getText("form", "OPTIONLIST_POSSIBILITIES"), "0")); 94 while( res.next() ) { 95 newOptionList.addElement( 96 new TKOptionFieldEntry( 97 res.getString("CONTENT_NODE_NAME"), 98 String.valueOf( res.getInt("CONTENT_NODE_ID") ) 99 ) 100 ); 101 } 102 res.close(); 103 optionList = newOptionList; 104 } 105 catch( SQLException e ) { 106 TKHttp.out().println("<br><b>ERROR: </b>" + e); 107 return; 108 } 109 110 super.fillIntoTemplate( t, value, prefix ); 111 112 optionList = tmpOptionList; 113 } 114 115 124 public boolean equals (Object object) 125 { 126 if (! super.equals(object)) 127 { 128 return false; 129 } 130 131 TKContentNodeTypeSelectorField field = (TKContentNodeTypeSelectorField) object; 132 133 return (this.fNodeType == null ? field.fNodeType == null : this.fNodeType.equals(field.fNodeType)); 134 } 135 136 141 public int hashCode () 142 { 143 return super.hashCode(); 145 } 146 147 } 148 | Popular Tags |