001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.tag;
020
021import javax.servlet.jsp.tagext.Tag;
022
023import lucee.runtime.exp.ApplicationException;
024import lucee.runtime.exp.PageException;
025import lucee.runtime.ext.tag.TagImpl;
026
027// TODO tag invokeargument
028// attr omit
029
030/**
031* Required for cfhttp POST operations, cfhttpparam is used to specify the parameters necessary to 
032*        build a cfhttp POST.
033*
034*
035*
036**/
037public final class InvokeArgument extends TagImpl {
038        
039        /** A variable name for the data being passed. */
040        private String name;
041
042        /** Specifies the value of the variable being passed. */
043        private Object value;
044        private boolean omit;
045
046        
047
048
049        /** set the value value
050        * @param value value to set
051        **/
052        public void setValue(Object value)      {
053                this.value=value;
054        }
055
056        /** set the value name
057        * @param name value to set
058        **/
059        public void setName(String name)        {
060                this.name=name;
061        }
062
063        /**
064         * @param omit the omit to set
065         */
066        public void setOmit(boolean omit) {
067                this.omit = omit;
068        }
069
070        @Override
071        public int doStartTag() throws PageException    {
072                Tag parent=getParent();
073                while(parent!=null && !(parent instanceof Invoke)) {
074                        parent=parent.getParent();
075                }
076                
077                if(parent instanceof Invoke) {
078                        Invoke invoke = (Invoke)parent;
079                        invoke.setArgument(name,value);
080                }
081                else {
082                        throw new ApplicationException("Wrong Context, tag InvokeArgument must be inside a Invoke tag");        
083                }
084                return SKIP_BODY;
085        }
086
087        @Override
088        public int doEndTag()   {
089                return EVAL_PAGE;
090        }
091
092        @Override
093        public void release()   {
094                super.release();
095                value=null;
096                name=null;
097                omit=false;
098        }
099}