01: package simpleorm.simplewebapp.eg.database;
02:
03: import simpleorm.simplewebapp.core.WPage;
04: import simpleorm.simplewebapp.core.WPagelet;
05: import simpleorm.simplewebapp.core.WValidationException;
06: import simpleorm.simplewebapp.eg.dbute.WCreateDB;
07: import simpleorm.core.SConnection;
08:
09: /**
10: * Base class for the pages, inits db etc.
11: */
12: abstract class WTestPage extends WPage {
13: protected @Override
14: void onInitialize() throws Exception {
15: if (!WInitPage.isInitialized())
16: throw new WValidationException("Database not initialized",
17: null);
18: WCreateDB.dbConnect();
19: SConnection.begin();
20: }
21:
22: protected @Override
23: void onFinalize() throws Exception {
24: SConnection.commit();
25: SConnection.detachAndClose();
26: }
27:
28: abstract static class WTreePagelet extends WPagelet {
29:
30: public WTreePagelet(WUserTreePage page) {
31: super (page, "tree");
32: }
33:
34: }
35: }
|