01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/field/TKOptionFieldIterator.java,v 1.7 2001/01/04 14:58:11 alex Exp $
03: *
04: */
05: package com.teamkonzept.field;
06:
07: import com.teamkonzept.lib.*;
08: import com.teamkonzept.web.*;
09:
10: public class TKOptionFieldIterator implements TKListIterator {
11:
12: TKListIterator oldIterator;
13: String fieldName;
14: String listName;
15: TKVector selectList;
16:
17: public TKOptionFieldIterator(TKVector selectList, String fieldName,
18: TKListIterator oldIterator, String listName) {
19: this .oldIterator = oldIterator;
20: this .fieldName = fieldName;
21: this .listName = listName;
22: this .selectList = selectList;
23: }
24:
25: public boolean apply(TKTemplate t, int i, String currListName) {
26: TKHTMLTemplate template = (TKHTMLTemplate) t;
27: if (currListName.equalsIgnoreCase(listName)) {
28: if (i >= selectList.size())
29: return false;
30: TKOptionFieldEntry entry = (TKOptionFieldEntry) selectList
31: .get(i);
32: template.set("OPTION", entry.option);
33: template.set("VALUE", entry.value);
34: return true;
35: } else if (oldIterator != null) {
36: return oldIterator.apply(template, i, currListName);
37: } else {
38: return false;
39: }
40: }
41: }
|