001    package railo.runtime.tag;
002    
003    
004    import javax.servlet.jsp.tagext.Tag;
005    
006    import railo.runtime.exp.ApplicationException;
007    import railo.runtime.exp.PageException;
008    import railo.runtime.ext.tag.TagSupport;
009    
010    /**
011     * implementation of the tag Compiler
012     */
013    public class VideoPlayerParam extends TagSupport {
014            
015            private VideoPlayerParamBean param=new VideoPlayerParamBean();
016            
017            @Override
018            public void release() {
019                    super.release();
020                    param=new VideoPlayerParamBean();
021            }
022            
023            /**
024             * @param video the video to set
025             * @throws PageException 
026             */
027            public void setVideo(String video) throws PageException {
028                    param.setVideo(pageContext,video);
029            }
030    
031            /**
032             * @param flash the flash to set
033             */
034            public void setFlash(String flash) throws PageException {
035                    param.setFlash(pageContext,flash);
036            }
037    
038            /**
039             * @param show the show to set
040             */
041            public void setShow(String show) throws PageException {
042                    param.setShow(show);
043            }
044    
045            /**
046             * @param index the index to set
047             * @throws PageException 
048             */
049            public void setIndex(double dIndex) throws PageException {
050                    param.setIndex((int) dIndex);
051            }
052            /*public void setAutostart(boolean autostart) {
053                    param.setAutostart(autostart);
054            }*/
055            public void setTitle(String title) {
056                    param.setTitle(title);
057            }
058    
059            /**
060             * @param preview the preview to set
061             * @throws PageException 
062             */
063            public void setPreview(String preview) throws PageException {
064                    param.setImage(pageContext,preview);
065            }
066            public void setImage(String preview) throws PageException {
067                    param.setImage(pageContext,preview);
068            }
069            public void setLink(String link) {
070                    param.setLink(link);
071            }
072            public void setAuthor(String author) {
073                    param.setAuthor(author);
074            }
075                    
076            @Override
077            public int doStartTag() throws PageException    {
078    
079                    if(param.getFlash()==null && param.getVideo()==null)
080                            throw new ApplicationException("you have to define video or flash source");
081                    if(param.getFlash()!=null && param.getVideo()!=null)
082                            throw new ApplicationException("you can define only one source");
083                             
084                    
085                    // get VideoPlayer Tag
086                    Tag parent=getParent();
087                    while(parent!=null && !(parent instanceof VideoPlayerJW)) {
088                            parent=parent.getParent();
089                    }
090                    
091                    if(parent instanceof VideoPlayerJW) {
092                            VideoPlayerJW mail = (VideoPlayerJW)parent;
093                            mail.setParam(param);
094                    }
095                    else {
096                            throw new ApplicationException("Wrong Context, tag VideoPlayerParam must be inside a VideoPlayer tag"); 
097                    }
098                    return SKIP_BODY;
099            }
100        
101    }