1 64 65 package com.jcorporate.expresso.ext.taglib; 66 67 import com.jcorporate.expresso.core.misc.StringUtil; 68 import org.apache.struts.taglib.bean.DefineTag; 69 70 import javax.servlet.jsp.JspException ; 71 import javax.servlet.jsp.PageContext ; 72 73 74 80 public class ExSessionTag 81 extends DefineTag { 82 protected String db = null; 83 protected String dbToUse = null; 84 85 92 public int doStartTag() 93 throws JspException { 94 95 return (SKIP_BODY); 96 } 97 98 public String getDb() { 99 return (this.dbToUse); 100 } 101 102 public void setDb(String newDb) { 103 this.db = newDb; 104 } 105 106 111 public int doEndTag() throws JspException { 112 113 dbToUse = db; 115 116 if ((this.dbToUse == null) || (this.dbToUse.equals(""))) { 117 this.dbToUse = "default"; 118 } 119 120 Object value = this.value; 122 123 if ((value == null) && (body != null)) { 124 value = body; 126 } 127 if (value == null) { 128 129 value = pageContext.getRequest().getAttribute(property); 131 } 132 if (property.equals("db") && (value == null)) { 133 value = "default"; 134 } 135 if (value == null) { 136 throw new JspException ("Unable to find property '" + 137 StringUtil.notNull(property) + 138 "' in session"); 139 } 140 141 int inScope = PageContext.PAGE_SCOPE; 143 144 if ("request".equals(toScope)) { 145 inScope = PageContext.REQUEST_SCOPE; 146 } else if ("session".equals(toScope)) { 147 inScope = PageContext.SESSION_SCOPE; 148 } else if ("application".equals(toScope)) { 149 inScope = PageContext.APPLICATION_SCOPE; 150 } 151 152 pageContext.setAttribute(id, value, inScope); 153 154 155 return (EVAL_PAGE); 157 158 } 159 } 160 | Popular Tags |