01: package simpleorm.simplewebapp.core;
02:
03: import simpleorm.simplewebapp.scalarFields.WFieldString;
04: import simpleorm.simplewebapp.core.WMenuItemGlobal;
05: import simpleorm.simplewebapp.core.WMenuParentGlobal;
06:
07: import java.util.Collection;
08:
09: /**
10: * Pagelet used for displaying lists with sort and search.
11: * This is fairly specific in the types of field groups and layouts,
12: * but quite unspecific in the data source.
13: */
14: public class WPageletList extends WPagelet {
15:
16: WMenuItemGlobal listCrudItem;
17:
18: int rowIndex = -1;
19:
20: public final WFieldGroup sortFields = addGroup(this ,
21: new WFieldGroup("sort"));
22: public final WFieldString sorter = addField(sortFields,
23: new WFieldString("sorter"));
24:
25: public final WFieldGroup searchFields = addGroup(this ,
26: new WFieldGroup("search"));
27: public final WButton search = addNewButton("Search");
28:
29: public final WFieldGroupList listFields = addGroup(this ,
30: new WFieldGroupList("list"));
31:
32: public WPageletList(WPage wpage, String name) {
33: super (wpage, name);
34: }
35:
36: public boolean doListRow() throws Exception {
37: if (rowIndex < -1)
38: throw new WException("doListed after no more " + this );
39: boolean more = false;
40: if (!isErroneous())
41: more = onListRow();
42: if (more)
43: rowIndex++;
44: else
45: rowIndex = -2;
46: return more;
47: }
48:
49: public Collection<WField> getSearchFieldValues() {
50: return searchFields.getValues();
51: }
52:
53: public int getRowIndex() {
54: return rowIndex;
55: }
56:
57: ///////////////////////
58:
59: public WMenuItemGlobal getListCrudItem() {
60: return listCrudItem;
61: }
62:
63: public void setListCrudItem(WMenuItemGlobal listCrudItem) {
64: this.listCrudItem = listCrudItem;
65: }
66: }
|