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 an invalid value ["+type+"], valid values are [page,request]");
041        }
042    
043    
044            @Override
045            public int doStartTag() throws PageException    {
046                    if(showerror!=null) throw new AbortException(showerror);
047                    throw new railo.runtime.exp.Abort(type);
048            }
049    
050            @Override
051            public int doEndTag()   {
052                    return EVAL_PAGE;
053            }
054    
055            @Override
056            public void release()   {
057                    super.release();
058                    showerror=null;
059            this.type=railo.runtime.exp.Abort.SCOPE_REQUEST;
060            }
061    }