1 16 package com.blandware.atleap.webapp.taglib.core.grid; 17 18 import com.blandware.atleap.webapp.taglib.core.util.TaglibConstants; 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 22 import javax.servlet.jsp.JspException ; 23 import javax.servlet.jsp.JspTagException ; 24 import javax.servlet.jsp.PageContext ; 25 import javax.servlet.jsp.tagext.JspFragment ; 26 import javax.servlet.jsp.tagext.SimpleTagSupport ; 27 import java.io.IOException ; 28 29 63 public class ColumnTag extends SimpleTagSupport { 64 65 protected transient final Log log = LogFactory.getLog(ColumnTag.class); 66 67 70 protected String fieldName = null; 71 72 75 protected String fieldKey = null; 76 77 80 protected String nameVar = TaglibConstants.FIELD_NAME_ATTR; 81 82 85 protected String keyVar = TaglibConstants.FIELD_KEY_ATTR; 86 87 88 97 public String getFieldName() { 98 return fieldName; 99 } 100 101 106 public void setFieldName(String fieldName) { 107 this.fieldName = fieldName; 108 } 109 110 119 public String getFieldKey() { 120 return fieldKey; 121 } 122 123 128 public void setFieldKey(String fieldKey) { 129 this.fieldKey = fieldKey; 130 } 131 132 141 public String getNameVar() { 142 return nameVar; 143 } 144 145 150 public void setNameVar(String nameVar) { 151 this.nameVar = nameVar; 152 } 153 154 163 public String getKeyVar() { 164 return keyVar; 165 } 166 167 172 public void setKeyVar(String keyVar) { 173 this.keyVar = keyVar; 174 } 175 176 public void doTag() throws JspException , IOException { 177 178 PageContext pageContext = (PageContext ) getJspContext(); 179 180 GridTag parentGridTag = (GridTag) findAncestorWithClass(this, GridTag.class); 182 183 if ( parentGridTag == null ) { 184 JspTagException e = new JspTagException ("Parent tag is invalid! This tag is only valid when nested within 'grid' tag"); 185 throw e; 186 } 187 188 pageContext.setAttribute(nameVar, fieldName); 189 if ( fieldKey != null && fieldKey.length() > 0 ) { 190 pageContext.setAttribute(keyVar, fieldKey); 191 } 192 193 JspFragment body = getJspBody(); 194 if ( body != null ) { 195 body.invoke(null); 196 } 197 } 198 199 } 200 | Popular Tags |