1 13 package info.magnolia.cms.taglibs.util; 14 15 import javax.servlet.jsp.PageContext ; 16 import javax.servlet.jsp.tagext.BodyTagSupport ; 17 18 import org.apache.commons.lang.StringUtils; 19 20 21 26 public class StrToObj extends BodyTagSupport { 27 28 31 private static final long serialVersionUID = 222L; 32 33 private String var; 34 35 private String delims; 36 37 public void setVar(String var) { 38 this.var = var; 39 } 40 41 public void setDelims(String delims) { 42 this.delims = delims; 43 } 44 45 48 public int doEndTag() { 49 String str = getBodyContent().getString(); 50 if (StringUtils.isNotEmpty(str)) { 51 String [] obj = str.split(StringUtils.defaultString(this.delims, "\n")); pageContext.setAttribute(this.var, obj, PageContext.PAGE_SCOPE); 53 54 } 55 else { 56 pageContext.setAttribute(this.var, StringUtils.EMPTY, PageContext.PAGE_SCOPE); 57 } 58 return EVAL_PAGE; 59 } 60 61 64 public void release() { 65 this.var = null; 66 this.delims = null; 67 super.release(); 68 } 69 } 70 | Popular Tags |