001    package railo.runtime.tag;
002    
003    import javax.servlet.jsp.tagext.Tag;
004    
005    import railo.runtime.exp.ApplicationException;
006    import railo.runtime.ext.tag.TagSupport;
007    import railo.runtime.op.Caster;
008    
009    public class ProcResult extends TagSupport {
010            
011            private ProcResultBean result=new ProcResultBean();
012    
013            public void release() {
014                    result=new ProcResultBean();
015                    super.release();
016            }
017            
018            /**
019             * @param maxrows The maxrows to set.
020             */
021            public void setMaxrows(double maxrows) {
022                    result.setMaxrows(Caster.toIntValue(maxrows));
023            }
024    
025            /**
026             * @param name The name to set.
027             */
028            public void setName(String name) {
029                    result.setName(name);
030            }
031    
032            /**
033             * @param resultset The resultset to set.
034             * @throws ApplicationException 
035             */
036            public void setResultset(double resultset) throws ApplicationException {
037                    if(resultset<1)throw new ApplicationException("value of attribute resultset must be a numeric value greater or equal to 1");
038                    result.setResultset((int) resultset);
039            }       
040            public int doStartTag() throws ApplicationException {
041                    
042                    // provide to parent
043                    Tag parent=getParent();
044                    while(parent!=null && !(parent instanceof StoredProc)) {
045                            parent=parent.getParent();
046                    }
047                    
048                    if(parent instanceof StoredProc) {
049                            ((StoredProc)parent).addProcResult(result);
050                    }
051                    else {
052                            throw new ApplicationException("Wrong Context, tag ProcResult must be inside a StoredProc tag");        
053                    }
054                    return SKIP_BODY;
055            }
056    }