KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > tags > OlapModelTag


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.jpivot.tags;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.List JavaDoc;
17
18 import javax.servlet.http.HttpSession JavaDoc;
19 import javax.servlet.jsp.JspException JavaDoc;
20 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
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 /**
31  * places a table model into the session
32  */

33 public abstract class OlapModelTag extends BodyTagSupport JavaDoc {
34
35   private static Logger logger = Logger.getLogger(OlapModelTag.class);
36   
37   private List JavaDoc clickables;
38   private String JavaDoc 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 JavaDoc {
54     clickables = new ArrayList JavaDoc();
55     return EVAL_BODY_BUFFERED;
56   }
57   
58   public int doEndTag() throws JspException JavaDoc {
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 JavaDoc 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 JavaDoc e) {
85       logger.error(null, e);
86       throw new JspException JavaDoc(e);
87     }
88   }
89
90   protected abstract OlapModel getOlapModel(RequestContext context) throws Exception JavaDoc;
91
92   public void setQueryName(String JavaDoc queryName) {
93     this.queryName = queryName;
94   }
95   public void setStackMode(boolean stackMode) {
96     this.stackMode = stackMode;
97   }
98 }
99
Popular Tags