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 import javax.servlet.jsp.JspException ; 15 16 import org.mmbase.util.Casting; 17 18 import org.mmbase.util.logging.Logger; 19 import org.mmbase.util.logging.Logging; 20 21 31 32 public class TreeFileTag extends UrlTag { 33 34 private static final Logger log = Logging.getLoggerInstance(TreeFileTag.class); 35 protected Attribute objectList = Attribute.NULL; 36 protected TreeHelper th = new TreeHelper(); 37 38 protected Attribute notFound = Attribute.NULL; 39 40 public void setNotfound(String n) throws JspTagException { 41 notFound = getAttribute(n); 42 } 43 44 45 public int doStartTag() throws JspTagException { 46 if (page == Attribute.NULL) { 47 throw new JspTagException ("Attribute 'page' was not specified"); 48 } 49 if (objectList == Attribute.NULL) { 50 throw new JspTagException ("Attribute 'objectlist' was not specified"); 51 } 52 th.setCloud(getCloudVar()); 53 super.doStartTag(); 54 helper.setValue(new Comparable () { 55 final TreeFileTag t = TreeFileTag.this; 56 public String toString() { 57 try { 58 String string = t.getUrl(); 59 haveBody(); 62 return string; 63 } catch (Throwable e){ 64 return e.toString(); 65 } 66 } 67 public int compareTo(Object o) { 68 return toString().compareTo(Casting.toString(o)); 69 } 70 }); 71 return EVAL_BODY; } 74 75 protected String getPage() throws JspTagException { 76 String orgPage = super.getPage(); 77 String treePage = th.findTreeFile(orgPage, objectList.getString(this), pageContext.getSession()); 78 if (log.isDebugEnabled()) { 79 log.debug("Retrieving page '" + treePage + "'"); 80 } 81 82 if (treePage == null || "".equals(treePage)) { 83 throw new JspTagException ("Could not find page " + orgPage); 84 } 85 86 return treePage; 87 } 88 89 90 public int doAfterBody() throws JspException { 91 return helper.doAfterBody(); 92 } 93 94 public int doEndTag() throws JspTagException { 95 int retval = super.doEndTag(); 97 return retval; 98 } 99 100 public void doFinally() { 101 th.doFinally(); 102 super.doFinally(); 103 } 104 105 108 109 public void setObjectlist(String includePage) throws JspTagException { 110 objectList = getAttribute(includePage); 111 } 112 113 protected boolean doMakeRelative() { 115 log.debug("doMakeRelative() overridden!"); 116 return false; 117 } 118 119 protected String getUrl(boolean writeamp, boolean encode) throws JspTagException { 120 String url = ""; 121 try { 122 url = super.getUrl(writeamp, encode); 123 } catch (JspTagException e) { 124 if (!notFound.getString(this).equals("skip")) { 125 throw(e); 126 } 127 } 128 return url; 129 } 130 131 } 132 | Popular Tags |