1 23 package org.dbforms.taglib; 24 import org.dbforms.config.DbEventInterceptorData; 25 import org.dbforms.config.DbFormsConfig; 26 import org.dbforms.config.DbFormsConfigRegistry; 27 import org.dbforms.config.FieldValue; 28 import org.dbforms.config.ResultSetVector; 29 import org.dbforms.config.Table; 30 31 import org.dbforms.event.datalist.dao.DataSourceFactory; 32 33 import java.sql.Connection ; 34 import java.sql.SQLException ; 35 36 import java.util.List ; 37 38 import javax.servlet.http.HttpServletRequest ; 39 40 41 42 59 public class ConfTableData extends EmbeddedData 60 implements javax.servlet.jsp.tagext.TryCatchFinally { 61 private String filter; 62 63 private String foreignTable; 65 private String orderBy; 66 private String storeField; 67 private String visibleFields; 68 69 74 public void setFilter(String string) { 75 filter = string; 76 } 77 78 79 84 public String getFilter() { 85 return filter; 86 } 87 88 89 94 public void setForeignTable(String foreignTable) { 95 this.foreignTable = foreignTable; 96 } 97 98 99 104 public String getForeignTable() { 105 return foreignTable; 106 } 107 108 109 114 public void setOrderBy(String orderBy) { 115 this.orderBy = orderBy; 116 } 117 118 119 124 public String getOrderBy() { 125 return orderBy; 126 } 127 128 129 134 public void setStoreField(String storeField) { 135 this.storeField = storeField; 136 } 137 138 139 144 public String getStoreField() { 145 return storeField; 146 } 147 148 149 154 public void setVisibleFields(String visibleFields) { 155 this.visibleFields = visibleFields; 156 } 157 158 159 164 public String getVisibleFields() { 165 return visibleFields; 166 } 167 168 169 172 public void doCatch(Throwable t) throws Throwable { 173 throw t; 174 } 175 176 177 187 protected List fetchData(Connection con) throws SQLException { 188 try { 189 DbFormsConfig config = DbFormsConfigRegistry.instance().lookup(); 190 Table table = config.getTableByName(getForeignTable()); 191 FieldValue[] orderConstraint = table.createOrderFieldValues(getOrderBy(), 192 null, false); 193 FieldValue[] childFieldValues = table.getFilterFieldArray(getFilter(), 194 getParentForm().getLocale()); 195 DataSourceFactory qry = new DataSourceFactory(null, con, table); 196 qry.setSelect(childFieldValues, orderConstraint, null, null); 197 198 HttpServletRequest request = (HttpServletRequest ) pageContext 199 .getRequest(); 200 DbEventInterceptorData data = new DbEventInterceptorData(request, 201 getConfig(), con, table); 202 data.setAttribute(DbEventInterceptorData.PAGECONTEXT, 203 pageContext); 204 ResultSetVector rsv = qry.getCurrent(data, null, 0); 205 qry.close(); 206 207 return formatEmbeddedResultRows(rsv); 208 } catch (Exception e) { 209 throw new SQLException (e.getMessage()); 210 } 211 } 212 } 213 | Popular Tags |