1 10 package org.mmbase.bridge.jsp.taglib.containers; 11 12 import javax.servlet.jsp.JspTagException ; 13 14 import org.mmbase.bridge.*; 15 import org.mmbase.bridge.jsp.taglib.CloudReferrerTag; 16 import org.mmbase.bridge.jsp.taglib.util.Attribute; 17 import org.mmbase.bridge.util.Queries; 18 import org.mmbase.cache.CachePolicy; 19 20 27 public class ListContainerTag extends CloudReferrerTag implements QueryContainer { 28 29 private Query query = null; 30 private Attribute cachePolicy = Attribute.NULL; 31 private Attribute path = Attribute.NULL; 32 private Attribute searchDirs = Attribute.NULL; 33 private Attribute fields = Attribute.NULL; 34 protected Attribute nodes = Attribute.NULL; 35 protected String jspVar = null; 36 37 public void setCachepolicy(String t) throws JspTagException { 38 cachePolicy = getAttribute(t); 39 } 40 41 public void setPath(String t) throws JspTagException { 42 path = getAttribute(t); 43 } 44 45 public void setSearchdirs(String s) throws JspTagException { 46 searchDirs = getAttribute(s); 47 } 48 49 public void setFields(String f) throws JspTagException { 50 fields = getAttribute(f); 51 } 52 53 56 public void setNodes(String n) throws JspTagException { 57 nodes = getAttribute(n); 58 } 59 60 63 public void setJspvar(String jv) { 64 jspVar = jv; 65 } 66 67 68 public Query getQuery() { 69 if (query.isUsed()) query = (Query) query.clone(); 70 return query; 71 } 72 73 public Cloud getCloudVar() throws JspTagException { 75 if (query == null) return super.getCloudVar(); return query.getCloud(); 77 } 78 79 80 public int doStartTag() throws JspTagException { 81 if (getReferid() != null) { 82 query = (Query) getContextProvider().getContextContainer().getObject(getReferid()); 83 } else { 84 if (path == Attribute.NULL) { 85 throw new JspTagException ("Path attribute is mandatory"); 86 } 87 Cloud cloud = getCloudVar(); 88 query = cloud.createQuery(); 89 } 90 91 if (getId() != null) { getContextProvider().getContextContainer().register(getId(), query); 93 } 94 if (jspVar != null) { 95 pageContext.setAttribute(jspVar, query); 96 } 97 98 if (cachePolicy != Attribute.NULL) { 99 query.setCachePolicy(CachePolicy.getPolicy(cachePolicy.getValue(this))); 100 } 101 102 Queries.addPath(query, (String ) path.getValue(this), (String ) searchDirs.getValue(this)); 103 104 Queries.addFields(query, (String ) fields.getValue(this)); 105 106 Queries.addStartNodes(query, nodes.getString(this)); 107 108 return EVAL_BODY; 109 } 110 111 public int doAfterBody() throws JspTagException { 112 if (EVAL_BODY == EVAL_BODY_BUFFERED) { 113 try { 114 if (bodyContent != null) { 115 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 116 } 117 } catch (java.io.IOException ioe){ 118 throw new JspTagException (ioe.toString()); 119 } 120 } 121 return SKIP_BODY; 122 } 123 public int doEndTag() throws JspTagException { 124 query = null; 125 return super.doEndTag(); 126 } 127 128 public Object getCurrent() { 129 return null; 130 } 131 132 } 133 | Popular Tags |