KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > pageflow > TreeIncludeTag


1 /*
2  
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5  
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8  
9  */

10 package org.mmbase.bridge.jsp.taglib.pageflow;
11
12 import org.mmbase.bridge.jsp.taglib.util.Attribute;
13 import javax.servlet.jsp.JspTagException JavaDoc;
14
15 import org.mmbase.util.logging.Logger;
16 import org.mmbase.util.logging.Logging;
17
18 /**
19  * Like IncludeTag, but an entire tree of files is being probed to find the one
20  * that has the most specified value.
21  *
22  * This is a taglib-implementation of the 'TREEPART' command, but renamed to
23  * 'Treeinclude' for esthetic reasons :)
24  * A full description of this command can be found in the mmbase-taglib.xml file.
25  *
26  * @author Johannes Verelst
27  * @version $Id: TreeIncludeTag.java,v 1.15 2006/07/17 15:38:47 johannes Exp $
28  */

29
30 public class TreeIncludeTag extends IncludeTag {
31     
32     private static final Logger log = Logging.getLoggerInstance(TreeIncludeTag.class.getName());
33     protected Attribute objectList = Attribute.NULL;
34     private TreeHelper th = new TreeHelper();
35     
36     public int doStartTag() throws JspTagException JavaDoc {
37         if (objectList == Attribute.NULL) {
38             throw new JspTagException JavaDoc("Attribute 'objectlist' was not specified");
39         }
40         return super.doStartTag();
41     }
42
43     protected String JavaDoc getPage() throws JspTagException JavaDoc {
44         String JavaDoc orgPage = super.getPage();
45         String JavaDoc treePage = th.findTreeFile(orgPage, objectList.getString(this), pageContext.getSession());
46         if (log.isDebugEnabled()) {
47             log.debug("Retrieving page '" + treePage + "'");
48         }
49
50         if (treePage == null || "".equals(treePage)) {
51             throw new JspTagException JavaDoc("Could not find page " + orgPage);
52         }
53
54         return treePage;
55     }
56
57     public void doAfterBodySetValue() throws JspTagException JavaDoc {
58         // sigh, we would of course prefer to extend, but no multiple inheritance possible in Java..
59
th.setCloud(getCloudVar());
60     
61         // Let IncludeTag do the rest of the work
62
includePage();
63     }
64
65     public void doFinally() {
66         th.doFinally();
67         super.doFinally();
68     }
69     
70     public void setObjectlist(String JavaDoc p) throws JspTagException JavaDoc {
71         objectList = getAttribute(p);
72     }
73
74     protected String JavaDoc getUrl(boolean writeamp, boolean encode) throws JspTagException JavaDoc {
75         String JavaDoc url = "";
76         try {
77             url = super.getUrl(writeamp, encode);
78         } catch (JspTagException JavaDoc e) {
79             if (!notFound.getString(this).equals("skip")) {
80                 throw(e);
81             }
82         }
83         return url;
84     }
85
86     // override to cancel
87
protected boolean doMakeRelative() {
88         log.debug("doMakeRelative() overridden!");
89         return false;
90     }
91 }
92
Popular Tags