01: package simpleorm.simplewebapp.eg.token;
02:
03: import simpleorm.simplewebapp.core.*;
04: import simpleorm.simplewebapp.eg.dbute.WCreateDB;
05: import simpleorm.simplewebapp.eg.WTestGlobals;
06: import simpleorm.simplewebapp.scalarFields.WFieldString;
07:
08: import java.sql.Connection;
09: import java.sql.DatabaseMetaData;
10: import java.sql.ResultSet;
11:
12: public class WTableListPage extends WPage {
13:
14: public final WTableListPage.WListPagelet pagelet = new WTableListPage.WListPagelet(
15: this );
16: {
17: pagelet
18: .setListCrudItem(WTestGlobals.getGlobalMenus().token.rowList);
19: }
20:
21: Connection con;
22:
23: protected void onInitialize() throws Exception {
24: con = WCreateDB.openJdbc();
25: }
26:
27: protected void onFinalize() throws Exception {
28: if (con != null)
29: con.close();
30: }
31:
32: public static class WListPagelet extends WPageletList {
33:
34: final WFieldString keyWord = addField(searchFields,
35: new WFieldString("keyWord"));
36:
37: final WField schema = addField(listFields, new WFieldString(
38: "schema").setNotRetrieved(true));
39: final WField table = addField(listFields, new WFieldString(
40: "table").setNotRetrieved(true));
41: final WField type = addField(listFields, new WFieldString(
42: "type").setNotRetrieved(true));
43:
44: public WListPagelet(WPage wpage) {
45: super (wpage, "list");
46: }
47:
48: Connection getCon() {
49: return ((WTableListPage) getPage()).con;
50: }
51:
52: ResultSet allTables;
53:
54: public @Override
55: void onPostMaybeSubmitted() throws Exception {
56: // PostProcess to ensure any onSubmits in other Crud pagelets completes.
57: DatabaseMetaData dbmd = getCon().getMetaData();
58: String[] tableTypes = null; //{ "TABLE" };
59: allTables = dbmd.getTables(null, null, null, tableTypes);
60: }
61:
62: protected @Override
63: boolean onListRow() throws Exception {
64: if (!allTables.next())
65: return false;
66: schema.setValue(allTables.getString("TABLE_SCHEM"));
67: table.setValue(allTables.getString("TABLE_NAME"));
68: type.setValue(allTables.getString("TABLE_TYPE"));
69: return true;
70: }
71:
72: }
73: }
|