1 10 package org.mmbase.bridge.jsp.taglib.pageflow; 11 12 import org.mmbase.bridge.jsp.taglib.util.Attribute; 13 import javax.servlet.jsp.JspTagException ; 14 15 import org.mmbase.util.logging.Logger; 16 import org.mmbase.util.logging.Logging; 17 18 29 30 public class LeafFileTag extends UrlTag { 31 32 private static final Logger log = Logging.getLoggerInstance(LeafFileTag.class); 33 protected Attribute objectList = Attribute.NULL; 34 protected TreeHelper th = new TreeHelper(); 35 36 protected Attribute notFound = Attribute.NULL; 37 38 public void setNotfound(String n) throws JspTagException { 39 notFound = getAttribute(n); 40 } 41 42 public int doStartTag() throws JspTagException { 43 if (page == Attribute.NULL) { 44 throw new JspTagException ("Attribute 'page' was not specified"); 45 } 46 if (objectList == Attribute.NULL) { 47 throw new JspTagException ("Attribute 'objectlist' was not specified"); 48 } 49 return super.doStartTag(); 50 } 51 protected String getPage() throws JspTagException { 52 String orgPage = super.getPage(); 53 String leafPage = th.findLeafFile(orgPage, objectList.getString(this), pageContext.getSession()); 54 if (log.isDebugEnabled()) { 55 log.debug("Retrieving page '" + leafPage + "'"); 56 } 57 58 if (leafPage == null || "".equals(leafPage)) { 59 throw new JspTagException ("Could not find page " + orgPage); 60 } 61 62 return leafPage; 63 } 64 65 public int doEndTag() throws JspTagException { 66 th.setCloud(getCloudVar()); 67 int retval = super.doEndTag(); 68 return retval; 69 } 70 71 public void doFinally() { 72 th.doFinally(); 73 super.doFinally(); 74 } 75 76 public void setObjectlist(String p) throws JspTagException { 77 objectList = getAttribute(p); 78 } 79 80 protected String getUrl(boolean writeamp, boolean encode) throws JspTagException { 81 String url = ""; 82 try { 83 url = super.getUrl(writeamp, encode); 84 } catch (JspTagException e) { 85 if (!notFound.getString(this).equals("skip")) { 86 throw(e); 87 } 88 } 89 return url; 90 } 91 92 protected boolean doMakeRelative() { 94 log.debug("doMakeRelative() overridden!"); 95 return false; 96 } 97 } 98 | Popular Tags |