1 17 18 package org.ajaxanywhere; 19 20 import javax.servlet.jsp.tagext.BodyTagSupport ; 21 import javax.servlet.jsp.tagext.TagSupport ; 22 import javax.servlet.jsp.JspException ; 23 import javax.servlet.jsp.PageContext ; 24 import javax.servlet.ServletRequest ; 25 import java.io.IOException ; 26 27 32 public class ZoneTag extends TagSupport { 33 private static final boolean DEFAULT_SKIP_INF_NOT_INCLUDED = false; 34 35 private String name; 36 private boolean skipIfNotIncluded = DEFAULT_SKIP_INF_NOT_INCLUDED; 37 38 public String getName() { 39 return name; 40 } 41 42 49 public void setName(String name) { 50 this.name = name; 51 } 52 53 public int doStartTag() throws JspException { 54 try { 55 pageContext.getOut().print(AAUtils.getZoneStartDelimiter(name)); 56 } catch (IOException e) { 57 throw new JspException (e); 58 } 59 60 ServletRequest request = pageContext.getRequest(); 61 if (skipIfNotIncluded 62 && AAUtils.isAjaxRequest(request) 63 && !AAUtils.getZonesToRefresh(request).contains(name) 64 ) 65 return SKIP_BODY; 66 else 67 return EVAL_BODY_INCLUDE; 68 69 } 70 71 public int doEndTag() throws JspException { 72 try { 73 pageContext.getOut().print(AAUtils.getZoneEndDelimiter(name)); 74 } catch (IOException e) { 75 throw new JspException (e); 76 } 77 return EVAL_PAGE; 78 } 79 80 public int doAfterBody() throws JspException { 81 return super.doAfterBody(); 82 } 83 84 85 public void setPageContext(PageContext pageContext) { 86 skipIfNotIncluded = DEFAULT_SKIP_INF_NOT_INCLUDED; 87 super.setPageContext(pageContext); 88 } 89 90 public boolean isSkipIfNotIncluded() { 91 return skipIfNotIncluded; 92 } 93 94 101 public void setSkipIfNotIncluded(boolean skipIfNotIncluded) { 102 this.skipIfNotIncluded = skipIfNotIncluded; 103 } 104 } 105 | Popular Tags |