001    package railo.runtime.ext.tag;
002    
003    import javax.servlet.jsp.JspException;
004    import javax.servlet.jsp.tagext.Tag;
005    
006    import railo.loader.engine.CFMLEngineFactory;
007    import railo.runtime.PageContext;
008    import railo.runtime.exp.PageException;
009    import railo.runtime.util.Excepton;
010    
011    /**
012     * Implementation of the Tag
013     */
014    public abstract class TagSupport implements Tag {
015    
016        /**
017         * Field <code>pageContext</code>
018         */
019        protected PageContext pageContext;
020        
021        private Tag parent;
022           
023        /**
024         * sets a Railo PageContext
025         * @param pageContext
026         */
027        public void setPageContext(PageContext pageContext) {
028            this.pageContext=pageContext;
029        }
030        /**
031         * @see javax.servlet.jsp.tagext.Tag#setPageContext(javax.servlet.jsp.PageContext)
032         */
033        public void setPageContext(javax.servlet.jsp.PageContext pageContext) {
034            this.pageContext=(PageContext) pageContext;
035        }
036    
037        /**
038         * @see javax.servlet.jsp.tagext.Tag#setParent(javax.servlet.jsp.tagext.Tag)
039         */
040        public void setParent(Tag parent) {
041            this.parent=parent;
042        }
043    
044        /**
045         * @see javax.servlet.jsp.tagext.Tag#getParent()
046         */
047        public Tag getParent() {
048            return parent;
049        }
050    
051        /**
052         * @see javax.servlet.jsp.tagext.Tag#doStartTag()
053         */
054        public int doStartTag() throws JspException {
055            return SKIP_BODY;
056        }
057    
058        /**
059         * @see javax.servlet.jsp.tagext.Tag#doEndTag()
060         */
061        public int doEndTag() throws JspException {
062            return EVAL_PAGE;
063        }
064    
065        /**
066         * @see javax.servlet.jsp.tagext.Tag#release()
067         */
068        public void release() {
069            pageContext=null;
070            parent=null;
071        }    
072        
073        /**
074         * check if value is not empty
075         * @param tagName 
076         * @param actionName 
077         * @param attributeName 
078         * @param attribute 
079         * @throws PageException
080         */
081        public void required(String tagName, String actionName, String attributeName, Object attribute) throws PageException {
082            if(attribute==null) {
083                Excepton util = CFMLEngineFactory.getInstance().getExceptionUtil();
084                throw util.createApplicationException("Attribute ["+attributeName+"] for tag ["+tagName+"] is required if attribute action has the value ["+actionName+"]");
085            }
086        }
087        
088        
089        
090    }