001 package railo.runtime.tag; 002 003 import railo.runtime.exp.AbortException; 004 import railo.runtime.exp.ApplicationException; 005 import railo.runtime.exp.PageException; 006 import railo.runtime.ext.tag.TagImpl; 007 008 /** 009 * Stops processing of a page at the tag location. Railo returns everything that was processed before the cfabort tag. The cfabort tag is often used with conditional logic to stop processing a page when a condition occurs. 010 * 011 * 012 * 013 **/ 014 public final class Abort extends TagImpl { 015 016 /** The error to display when cfabort executes. 017 ** The error message displays in the standard CFML error page. */ 018 private String showerror; 019 private int type=railo.runtime.exp.Abort.SCOPE_REQUEST; 020 021 /** set the value showerror 022 * The error to display when cfabort executes. 023 * The error message displays in the standard CFML error page. 024 * @param showerror value to set 025 **/ 026 public void setShowerror(String showerror) { 027 this.showerror=showerror; 028 } 029 030 031 /** 032 * sets the type of the abort (page,request) 033 * @param type 034 * @throws ApplicationException 035 */ 036 public void setType(String type) throws ApplicationException { 037 type=type.toLowerCase().trim(); 038 if(type.equals("page"))this.type=railo.runtime.exp.Abort.SCOPE_PAGE; 039 else if(type.equals("request"))this.type=railo.runtime.exp.Abort.SCOPE_REQUEST; 040 else throw new ApplicationException("attribute type has a invalid value ["+type+"], valid values are [page,request]"); 041 } 042 043 044 /** 045 * @see javax.servlet.jsp.tagext.Tag#doStartTag() 046 */ 047 public int doStartTag() throws PageException { 048 if(showerror!=null) throw new AbortException(showerror); 049 throw new railo.runtime.exp.Abort(type); 050 } 051 052 /** 053 * @see javax.servlet.jsp.tagext.Tag#doEndTag() 054 */ 055 public int doEndTag() { 056 return EVAL_PAGE; 057 } 058 059 /** 060 * @see javax.servlet.jsp.tagext.Tag#release() 061 */ 062 public void release() { 063 super.release(); 064 showerror=null; 065 this.type=railo.runtime.exp.Abort.SCOPE_REQUEST; 066 } 067 }