Save This Page
Home » glassfish-v2ur2-b04-src » javax » servlet » jsp » tagext » [javadoc | source]
    1   /*
    2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    3    * 
    4    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    5    * 
    6    * Portions Copyright Apache Software Foundation.
    7    * 
    8    * The contents of this file are subject to the terms of either the GNU
    9    * General Public License Version 2 only ("GPL") or the Common Development
   10    * and Distribution License("CDDL") (collectively, the "License").  You
   11    * may not use this file except in compliance with the License. You can obtain
   12    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   13    * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   14    * language governing permissions and limitations under the License.
   15    * 
   16    * When distributing the software, include this License Header Notice in each
   17    * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   18    * Sun designates this particular file as subject to the "Classpath" exception
   19    * as provided by Sun in the GPL Version 2 section of the License file that
   20    * accompanied this code.  If applicable, add the following below the License
   21    * Header, with the fields enclosed by brackets [] replaced by your own
   22    * identifying information: "Portions Copyrighted [year]
   23    * [name of copyright owner]"
   24    * 
   25    * Contributor(s):
   26    * 
   27    * If you wish your version of this file to be governed by only the CDDL or
   28    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   29    * elects to include this software in this distribution under the [CDDL or GPL
   30    * Version 2] license."  If you don't indicate a single choice of license, a
   31    * recipient has the option to distribute your version of this file under
   32    * either the CDDL, the GPL Version 2 or to extend the choice of license to
   33    * its licensees as provided above.  However, if you add GPL Version 2 code
   34    * and therefore, elected the GPL Version 2 license, then the option applies
   35    * only if the new code is made subject to such option by the copyright
   36    * holder.
   37    */
   38    
   39   package javax.servlet.jsp.tagext;
   40   
   41   import java.io.IOException;
   42   import java.io.Writer;
   43   import javax.servlet.jsp;
   44   
   45   /**
   46    * Encapsulates a portion of JSP code in an object that 
   47    * can be invoked as many times as needed.  JSP Fragments are defined 
   48    * using JSP syntax as the body of a tag for an invocation to a SimpleTag 
   49    * handler, or as the body of a <jsp:attribute> standard action
   50    * specifying the value of an attribute that is declared as a fragment,
   51    * or to be of type JspFragment in the TLD.
   52    * <p>
   53    * The definition of the JSP fragment must only contain template 
   54    * text and JSP action elements.  In other words, it must not contain
   55    * scriptlets or scriptlet expressions.  At translation time, the 
   56    * container generates an implementation of the JspFragment abstract class
   57    * capable of executing the defined fragment.
   58    * <p>
   59    * A tag handler can invoke the fragment zero or more times, or 
   60    * pass it along to other tags, before returning.  To communicate values
   61    * to/from a JSP fragment, tag handlers store/retrieve values in 
   62    * the JspContext associated with the fragment.
   63    * <p>
   64    * Note that tag library developers and page authors should not generate
   65    * JspFragment implementations manually.
   66    * <p>
   67    * <i>Implementation Note</i>: It is not necessary to generate a 
   68    * separate class for each fragment.  One possible implementation is 
   69    * to generate a single helper class for each page that implements 
   70    * JspFragment. Upon construction, a discriminator can be passed to 
   71    * select which fragment that instance will execute.
   72    *
   73    * @since 2.0
   74    */
   75   public abstract class JspFragment {
   76   
   77       /**
   78        * Executes the fragment and directs all output to the given Writer,
   79        * or the JspWriter returned by the getOut() method of the JspContext
   80        * associated with the fragment if out is null.
   81        *
   82        * @param out The Writer to output the fragment to, or null if 
   83        *     output should be sent to JspContext.getOut().
   84        * @throws javax.servlet.jsp.JspException Thrown if an error occured
   85        *     while invoking this fragment.
   86        * @throws javax.servlet.jsp.SkipPageException Thrown if the page
   87        *     that (either directly or indirectly) invoked the tag handler that
   88        *     invoked this fragment is to cease evaluation.  The container
   89        *     must throw this exception if a Classic Tag Handler returned
   90        *     Tag.SKIP_PAGE or if a Simple Tag Handler threw SkipPageException.
   91        * @throws java.io.IOException If there was an error writing to the 
   92        *     stream.
   93        */
   94       public abstract void invoke( Writer out )
   95           throws JspException, IOException;
   96   
   97       /**
   98        * Returns the JspContext that is bound to this JspFragment.
   99        *
  100        * @return The JspContext used by this fragment at invocation time.
  101        */
  102       public abstract JspContext getJspContext();
  103   
  104   }

Save This Page
Home » glassfish-v2ur2-b04-src » javax » servlet » jsp » tagext » [javadoc | source]