1 package com.tonbeller.jpivot.table.navi; 2 3 import java.util.Collection ; 4 import java.util.Iterator ; 5 6 import com.tonbeller.jpivot.olap.model.Member; 7 import com.tonbeller.jpivot.olap.model.OlapModel; 8 import com.tonbeller.jpivot.olap.model.Property; 9 import com.tonbeller.jpivot.param.ParameterProvider; 10 import com.tonbeller.wcf.controller.Controller; 11 import com.tonbeller.wcf.controller.RequestContext; 12 import com.tonbeller.wcf.controller.RequestListener; 13 import com.tonbeller.wcf.param.SessionParam; 14 import com.tonbeller.wcf.param.SessionParamPool; 15 16 23 public class DynamicClickableMember extends ClickableMemberSupport { 24 private String page; 25 private ParameterProvider paramProvider; 26 private String menuLabel; 27 28 37 public DynamicClickableMember(String uniqueName, String menuLabel, ParameterProvider paramProvider, String page) { 38 super(uniqueName); 39 this.menuLabel = menuLabel; 40 this.paramProvider = paramProvider; 41 this.page = page; 42 } 43 44 private class AddMemberToParameterPool implements RequestListener { 45 private Member member; 46 private OlapModel model; 47 52 private static final String PAGE_PROPERTY = "$page"; 53 54 AddMemberToParameterPool(OlapModel model, Member m) { 55 this.model = model; 56 this.member = m; 57 } 58 59 public void request(RequestContext context) throws Exception { 60 SessionParamPool pool = SessionParamPool.instance(context.getSession()); 61 Collection c = paramProvider.createSessionParams(model, member); 62 for (Iterator it = c.iterator(); it.hasNext();) 63 pool.setParam((SessionParam) it.next()); 64 65 if (page == null) { 68 Property prop = member.getProperty(PAGE_PROPERTY); 69 if (prop != null) 70 page = prop.getValue(); 71 } 72 73 if (page != null) 74 Controller.instance(context.getSession()).setNextView(page); 75 } 76 } 77 78 protected RequestListener createRequestListener(OlapModel model, Member m) { 79 return new AddMemberToParameterPool(model, m); 80 } 81 82 public String getMenuLabel() { 83 return menuLabel; 84 } 85 } | Popular Tags |