01: package simpleorm.simplewebapp.eg.token;
02:
03: import simpleorm.simplewebapp.core.*;
04: import simpleorm.simplewebapp.scalarFields.WFieldString;
05: import simpleorm.simplewebapp.scalarFields.WFieldImage;
06: import simpleorm.simplewebapp.eg.WTestGlobals;
07:
08: import java.util.Iterator;
09:
10: import rsa.edp.simplecrypt.WTokenDatabase;
11: import rsa.edp.simplecrypt.WTokenRecord;
12:
13: public class WTokenListPage extends WPage {
14:
15: public final WTokenListPage.WListTokenPagelet pagelet = new WTokenListPage.WListTokenPagelet(
16: this );
17: {
18: pagelet
19: .setListCrudItem(WTestGlobals.getGlobalMenus().token.tokenCrud);
20: }
21:
22: protected void onInitialize() throws Exception {
23: WTokenDatabase.db.beginTransaction();
24: }
25:
26: protected void onFinalize() throws Exception {
27: WTokenDatabase.db.endTransaction();
28: }
29:
30: public static class WListTokenPagelet extends WPageletList {
31:
32: final WFieldString keyWord = addField(searchFields,
33: new WFieldString("keyWord"));
34:
35: final WField serial = addField(listFields, new WFieldString(
36: "serial").setNotRetrieved(true));
37: final WField custom = addField(listFields, new WFieldString(
38: "custom").setNotRetrieved(true));
39: final WField customImg = addField(listFields, new WFieldImage(
40: "customImg").setNotRetrieved(true));
41: final WField keys = addField(listFields, new WFieldString(
42: "keys").setNotRetrieved(true));
43: final WField status = addField(listFields, new WFieldString(
44: "status").setNotRetrieved(true));
45: final WField comment = addField(listFields, new WFieldString(
46: "comment").setNotRetrieved(true));
47:
48: public WListTokenPagelet(WPage wpage) {
49: super (wpage, "list");
50:
51: }
52:
53: Iterator<WTokenRecord> iter;
54:
55: public void onPostMaybeSubmitted() {
56: // PostProcess to ensure any onSubmits in other Crud pagelets completes.
57: iter = WTokenDatabase.db.getIterator(keyWord.getText(),
58: sorter.getText());
59: }
60:
61: protected @Override
62: boolean onListRow() throws Exception {
63: if (!iter.hasNext())
64: return false;
65: WBeanUtils.retrieveBeanProperties(iter.next(), listFields
66: .getFields().values());
67: listFields.setAnchorHRefFields(serial);
68: return true;
69: }
70:
71: }
72: }
|