KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > form > TestItems


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.form;
14
15 import org.w3c.dom.Element JavaDoc;
16
17 import com.tonbeller.wcf.component.FormListener;
18 import com.tonbeller.wcf.controller.RequestContext;
19 import com.tonbeller.wcf.ui.ListItem;
20 import com.tonbeller.wcf.ui.Select;
21 import com.tonbeller.wcf.utils.DomUtils;
22
23 /**
24  * Example of dynamic list items
25  * @author av
26  */

27 public class TestItems extends NodeHandlerSupport implements FormListener {
28   String JavaDoc id = DomUtils.randomId();
29   /**
30    * creates a few items
31    */

32   public void revert(RequestContext context) {
33     Element JavaDoc list = getElement();
34     Select.removeAllItems(list);
35     for (int i = 0; i < 10; i++) {
36       Element JavaDoc item = ListItem.addListItem(list);
37       ListItem.setId(item, id + "." + i);
38       ListItem.setValue(item, "" + i);
39       ListItem.setLabel(item, "item " + (i + 1));
40     }
41   }
42
43
44   /**
45    * always true
46    */

47   public boolean validate(RequestContext context) {
48     return true;
49   }
50
51   /**
52    * @see com.tonbeller.wcf.component.NodeHandler#initialize(Environment, Component, Element)
53    */

54   public void initialize(RequestContext context, XmlComponent comp, Element JavaDoc element) throws Exception JavaDoc {
55     super.initialize(context, comp, element);
56     comp.addFormListener(this);
57     revert(context);
58   }
59
60 }
61
Popular Tags