1 5 package com.tonbeller.wcf.popup; 6 7 import java.util.ArrayList ; 8 import java.util.Iterator ; 9 import java.util.List ; 10 11 import javax.servlet.http.HttpSessionBindingEvent ; 12 import javax.servlet.http.HttpSessionBindingListener ; 13 14 import com.tonbeller.wcf.controller.Dispatcher; 15 import com.tonbeller.wcf.controller.DispatcherSupport; 16 import com.tonbeller.wcf.controller.RequestContext; 17 import com.tonbeller.wcf.controller.WcfController; 18 19 public class TestBean implements HttpSessionBindingListener { 20 21 Dispatcher disp = new DispatcherSupport(); 22 String lastItem; 23 24 27 public PopUp getPopUp0() { 28 PopUp p = new PopUp(); 29 p.setLabel("popup 0"); 30 List items = new ArrayList (); 31 addItems(items); 32 for (Iterator it = items.iterator(); it.hasNext();) { 33 Item item = (Item) it.next(); 34 p.addItem(item); 35 } 36 return p; 37 } 38 39 42 public PopUp getPopUp1a() { 43 PopUp p = new PopUp(); 44 p.setLabel("popup 1a"); 45 GroupItem g = new GroupItemSupport(); 47 addItems(g.getChildren()); 48 p.addItem(g); 49 return p; 50 } 51 52 55 public PopUp getPopUp1b() { 56 PopUp p = new PopUp(); 57 p.setLabel("popup 1b"); 58 GroupItem g = new GroupItemSupport("Group 1"); 60 addItems(g.getChildren()); 61 p.addItem(g); 62 return p; 63 } 64 65 public PopUp getPopUp2() { 66 PopUp p = new PopUp(); 67 p.setLabel("popup 2"); 68 69 GroupItem g = new GroupItemSupport("Group 1"); 70 addItems(g.getChildren()); 71 p.addItem(g); 72 73 g = new GroupItemSupport("Group 2", "/wcf/table/page-last.png"); 74 addItems(g.getChildren()); 75 p.addItem(g); 76 77 g = new GroupItemSupport("Group 3 is empty", "/wcf/table/page-first.png"); 78 p.addItem(g); 79 80 g = new GroupItemSupport("Group 4", "/wcf/table/page-first.png"); 81 addItems(g.getChildren()); 82 p.addItem(g); 83 GroupItem sub = new GroupItemSupport("Group 4.1"); 84 addItems(sub.getChildren()); 85 g.getChildren().add(sub); 86 addItems(g.getChildren()); 87 sub = new GroupItemSupport("Group 4.2", "/wcf/table/page-first.png"); 88 addItems(sub.getChildren()); 89 g.getChildren().add(sub); 90 addItems(g.getChildren()); 91 92 return p; 93 } 94 95 private void addItems(List list) { 96 MenuItemSupport m; 97 m = new WcfMenuItem(disp, "Item 1") { 98 public void request(RequestContext context) throws Exception { 99 lastItem = "Item 1"; 100 } 101 }; 102 list.add(m); 103 m = new WcfMenuItem(disp, "Item 2", "/wcf/tree/accept.png") { 104 public void request(RequestContext context) throws Exception { 105 lastItem = "Item 2"; 106 } 107 }; 108 list.add(m); 109 } 110 111 public String getLastItem() { 112 disp.clear(); 113 return lastItem; 114 } 115 116 public void setLastItem(String lastItem) { 117 this.lastItem = lastItem; 118 } 119 120 public void valueBound(HttpSessionBindingEvent e) { 121 WcfController.instance(e.getSession()).addRequestListener(disp); 122 } 123 124 public void valueUnbound(HttpSessionBindingEvent e) { 125 } 126 127 } 128 | Popular Tags |