KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.mmbase.bridge.jsp.taglib.util.Attribute;
12 import javax.servlet.jsp.JspTagException JavaDoc;
13
14 import org.mmbase.util.logging.Logger;
15 import org.mmbase.util.logging.Logging;
16
17 /**
18  * Like IncludeTag, but an entire tree of files is being probed to find the one
19  * that has the most specified value.
20  *
21  * This is a taglib-implementation of the 'LEAFPART' command
22  * A full description of this command can be found in the mmbase-taglib.xml file.
23  *
24  * @author Johannes Verelst
25  * @version $Id: LeafIncludeTag.java,v 1.15 2006/07/17 15:38:47 johannes Exp $
26  */

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