001    package railo.runtime.tag;
002    
003    import railo.runtime.exp.PageException;
004    import railo.runtime.ext.tag.BodyTagTryCatchFinallyImpl;
005    
006    /**
007    * Saves the generated content inside the tag body in a variable.
008    *
009    *
010    *
011    **/
012    public final class SaveContent extends BodyTagTryCatchFinallyImpl {
013    
014            /** The name of the variable in which to save the generated content inside the tag. */
015            private String variable;
016            private boolean trim;
017            
018            /**
019            * @see javax.servlet.jsp.tagext.Tag#release()
020            */
021            public void release()   {
022                    super.release();
023                    variable=null;
024                    trim=false;
025            }
026    
027    
028            /** set the value variable
029            *  The name of the variable in which to save the generated content inside the tag.
030            * @param variable value to set
031            **/
032            public void setVariable(String variable)        {
033                    this.variable=variable;
034            }
035            
036    
037            public void setTrim(boolean trim)       {
038                    this.trim=trim;
039            }
040            
041            /**
042            * @see javax.servlet.jsp.tagext.Tag#doStartTag()
043            */
044            public int doStartTag() {
045                    return EVAL_BODY_BUFFERED;
046            }
047    
048    
049            /**
050            * @see javax.servlet.jsp.tagext.BodyTag#doAfterBody()
051            */
052            public int doAfterBody() throws PageException   {
053                    pageContext.setVariable(variable,trim?bodyContent.getString().trim():bodyContent.getString());
054                    bodyContent.clearBody();
055                    
056                    return SKIP_BODY;
057            }
058    
059            
060            
061            
062            
063            
064    }