01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/field/TKSwitchListShowIterator.java,v 1.7 2000/10/13 13:54:22 alex Exp $
03: *
04: */
05: package com.teamkonzept.field;
06:
07: import com.teamkonzept.lib.*;
08: import com.teamkonzept.web.*;
09:
10: public class TKSwitchListShowIterator implements TKListIterator {
11:
12: TKListIterator oldIterator;
13: String switchListName;
14: TKEmbededSwitch embededSwitch;
15: TKVector dataVector;
16: int entryCount;
17: String scope;
18: String listName;
19:
20: public TKSwitchListShowIterator(TKVector dataVector,
21: TKEmbededSwitch embededSwitch, String scope,
22: String switchListName, TKListIterator oldIterator) {
23: this .oldIterator = oldIterator;
24: this .embededSwitch = embededSwitch;
25: this .switchListName = switchListName;
26: this .dataVector = dataVector;
27: this .scope = scope;
28: this .entryCount = dataVector.size();
29: this .listName = scope + "." + switchListName;
30: }
31:
32: public boolean apply(TKTemplate t, int i, String currListName) {
33: TKHTMLTemplate template = (TKHTMLTemplate) t;
34:
35: if (currListName.equalsIgnoreCase(listName)) {
36: if (i >= entryCount)
37: return false;
38: Object data = dataVector.get(i);
39: template.set("SCOPE", listName);
40: template.set(listName + ".IDX", String.valueOf(i + 1));
41: embededSwitch.setEmbedName(switchListName);
42: embededSwitch.fillIntoPresentation(template, data, scope);
43: return true;
44: } else if (oldIterator != null) {
45: return oldIterator.apply(template, i, currListName);
46: } else {
47: return false;
48: }
49: }
50: }
|