1 13 package com.tonbeller.jpivot.tags; 14 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 import javax.servlet.http.HttpSession ; 19 import javax.servlet.jsp.JspException ; 20 import javax.servlet.jsp.tagext.BodyTagSupport ; 21 22 import org.apache.log4j.Logger; 23 24 import com.tonbeller.jpivot.olap.model.OlapModel; 25 import com.tonbeller.jpivot.olap.navi.ClickableExtension; 26 import com.tonbeller.jpivot.olap.navi.ClickableExtensionImpl; 27 import com.tonbeller.jpivot.table.ClickableMember; 28 import com.tonbeller.wcf.controller.RequestContext; 29 30 33 public abstract class OlapModelTag extends BodyTagSupport { 34 35 private static Logger logger = Logger.getLogger(OlapModelTag.class); 36 37 private List clickables; 38 private String queryName; 39 private boolean stackMode = true; 40 41 public OlapModelTag() { 42 } 43 44 public void release() { 45 super.release(); 46 stackMode = true; 47 } 48 49 public void addClickable(ClickableMember clickable) { 50 clickables.add(clickable); 51 } 52 53 public int doStartTag() throws JspException { 54 clickables = new ArrayList (); 55 return EVAL_BODY_BUFFERED; 56 } 57 58 public int doEndTag() throws JspException { 59 try { 60 logger.info("enter"); 61 RequestContext context = RequestContext.instance(); 62 OlapModel om = getOlapModel(context); 63 om = (OlapModel) om.getTopDecorator(); 64 om.setLocale(context.getLocale()); 65 om.setID(id); 66 67 HttpSession session = pageContext.getSession(); 68 om.setServletContext(session.getServletContext()); 69 70 ClickableExtension ext = (ClickableExtension) om.getExtension(ClickableExtension.ID); 71 if (ext == null) { 72 ext = new ClickableExtensionImpl(); 73 om.addExtension(ext); 74 } 75 ext.setClickables(clickables); 76 77 OlapModelProxy omp = OlapModelProxy.instance(id, session, stackMode); 78 if (queryName != null) 79 omp.initializeAndShow(queryName, om); 80 else 81 omp.initializeAndShow(om); 82 83 return EVAL_PAGE; 84 } catch (Exception e) { 85 logger.error(null, e); 86 throw new JspException (e); 87 } 88 } 89 90 protected abstract OlapModel getOlapModel(RequestContext context) throws Exception ; 91 92 public void setQueryName(String queryName) { 93 this.queryName = queryName; 94 } 95 public void setStackMode(boolean stackMode) { 96 this.stackMode = stackMode; 97 } 98 } 99 | Popular Tags |