1 64 65 package com.jcorporate.expresso.ext.struts.taglib.bean; 66 67 import com.jcorporate.expresso.core.misc.StringUtil; 68 import com.jcorporate.expresso.ext.struts.taglib.ControllerUtils; 69 import org.apache.log4j.Logger; 70 import org.apache.struts.taglib.bean.DefineTag; 71 72 import javax.servlet.jsp.JspException ; 73 import javax.servlet.jsp.PageContext ; 74 75 76 82 public class ExDefineTag extends DefineTag { 83 private static final Logger log = Logger.getLogger(ExDefineTag.class); 84 85 86 93 public int doStartTag() throws JspException { 94 if (log.isDebugEnabled()) { 96 log.debug("******** ExDefineTag.doStartTag()"); 97 } 98 99 return (EVAL_BODY_TAG); 100 } 101 102 103 108 public int doEndTag() throws JspException { 109 110 if (log.isDebugEnabled()) { 111 log.debug("******** ExDefineTag.doEndTag()"); 112 } 113 114 Object value = this.value; 115 116 if ((value == null) && (body != null)) { 117 value = body; 119 } 120 if (value == null) { 121 122 value = ControllerUtils.getBeanProperty(pageContext, name, 124 property, false); 125 } 126 if (value == null) { 127 throw new JspException ("Unable to find property '" + 128 StringUtil.notNull(property) + 129 "' in bean '" + StringUtil.notNull(name) + 130 "'"); 131 } 132 133 int inScope = PageContext.PAGE_SCOPE; 135 136 if ("request".equals(toScope)) { 137 inScope = PageContext.REQUEST_SCOPE; 138 } else if ("session".equals(toScope)) { 139 inScope = PageContext.SESSION_SCOPE; 140 } else if ("application".equals(toScope)) { 141 inScope = PageContext.APPLICATION_SCOPE; 142 } 143 144 pageContext.setAttribute(id, value, inScope); 145 return (EVAL_PAGE); 147 148 } 149 150 } 151 | Popular Tags |