jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hor...@apache.org
Subject cvs commit: jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib EscapeHtmlTag.java
Date Mon, 18 Oct 2004 18:38:07 GMT
horwat      2004/10/18 11:38:07

  Modified:    standard/examples/src/org/apache/taglibs/standard/examples/taglib
                        Tag: STANDARD_1_0_BRANCH EscapeHtmlTag.java
  Log:
  Bugzilla #31701
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=31701
  
  Fixed the tag handler so that the example source will be properly displayed in a pre-JSP
2.0 container.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +26 -7     jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/EscapeHtmlTag.java
  
  Index: EscapeHtmlTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/EscapeHtmlTag.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- EscapeHtmlTag.java	28 Feb 2004 06:08:04 -0000	1.1.2.2
  +++ EscapeHtmlTag.java	18 Oct 2004 18:38:07 -0000	1.1.2.3
  @@ -25,6 +25,7 @@
   import javax.servlet.jsp.tagext.BodyTagSupport;
   
   import org.apache.taglibs.standard.examples.util.Util;
  +import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
   
   /**
    * <p>Tag handler for &lt;escapeHtml&gt;
  @@ -37,8 +38,8 @@
       //*********************************************************************
       // Instance variables
       
  -    private Object reader;
  -    private Object writer;
  +    private String reader;
  +    private String writer;
       
       //*********************************************************************
       // Constructors
  @@ -60,14 +61,14 @@
       /**
        * Tag's 'reader' attribute
        */
  -    public void setReader(Object reader) {
  +    public void setReader(String reader) {
           this.reader = reader;
       }
       
       /**
        * Tag's 'writer' attribute
        */
  -    public void setWriter(Object writer) {
  +    public void setWriter(String writer) {
           this.writer = writer;
       }
       
  @@ -86,13 +87,13 @@
               }
               in = Util.castToReader(bcs);
           } else {
  -            in = Util.castToReader(reader);
  +            in = Util.castToReader(eval("reader", reader, Object.class));
           }
           
           if (writer == null) {
               out = pageContext.getOut();
           } else {
  -            out = Util.castToWriter(writer);
  +            out = Util.castToWriter(eval("writer", writer, Object.class));
           }
           
           transform(in, out);
  @@ -131,6 +132,24 @@
           } catch (IOException ex) {
               throw new JspException("EscapeHtml: " +
               "error copying chars", ex);
  +        }
  +    }
  +
  +     
  +    //*********************************************************************
  +    // Utility methods
  +
  +    /**
  +     * Evaluate elexprvalue
  +     */
  +    private Object eval(String attName, String attValue, Class clazz)
  +    throws JspException {
  +        Object obj = ExpressionEvaluatorManager.evaluate(
  +        attName, attValue, clazz, this, pageContext);
  +        if (obj == null) {
  +            throw new NullAttributeException("escapeHtml", attName);
  +        } else {
  +            return obj;
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Mime
View raw message