You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by fe...@apache.org on 2004/03/12 06:25:36 UTC

cvs commit: jakarta-taglibs/string/src/org/apache/taglibs/string StringTagSupport.java

felipeal    2004/03/11 21:25:36

  Modified:    string/src/org/apache/taglibs/string StringTagSupport.java
  Log:
  changed doEndTag() logic to first call evaluateString() - that's necessary for tags that don't return a String (like split, which returns an array of Strings
  
  Revision  Changes    Path
  1.12      +34 -13    jakarta-taglibs/string/src/org/apache/taglibs/string/StringTagSupport.java
  
  Index: StringTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/StringTagSupport.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StringTagSupport.java	9 Mar 2004 00:54:45 -0000	1.11
  +++ StringTagSupport.java	12 Mar 2004 05:25:36 -0000	1.12
  @@ -92,33 +92,54 @@
                   ioe.printStackTrace();
               }
           }
  +
  +        // first, try to evaluate the string and associated the result on var
  +        Object result = evaluateString( text );
  +        if ( result != null && this.var != null ) {
  +            pageContext.setAttribute(this.var, result);
  +        } else {
  +          // then, try to transform it
  +          text = changeString(text);
           
  -        text = changeString(text);
  -        
  -        // TODO: RandomString is not working if body is set...
  -        /*
  -        System.err.println("...."+text+"....");
  -        if ( text  != null  ) {
  +          // TODO: RandomString is not working if body is set...
  +          /*
  +            System.err.println("...."+text+"....");
  +            if ( text  != null  ) {
           	System.out.println( "length = " + text.length());
  -        }
  -        */
  +            }
  +          */
           
  -        if(this.var == null) {
  +          if(this.var == null) {
               JspWriter writer = pageContext.getOut();
               try {
  -                writer.print(text);
  +              writer.print(text);
               } catch (IOException e) {
  -                throw new JspException(e.toString());
  +              throw new JspException(e.toString());
               }
  -        } else {
  +          } else {
               pageContext.setAttribute(this.var, text);
  +          }
  +
           }
   
           return (EVAL_PAGE);
       }
   
       /** 
  -     * Perform an operation on the passed in String.
  +     * Perform an operation on the passed String.
  +     * The object returned by this operation (if not null) will be
  +     * associated to PageContext attribute represented by this.var.
  +     *
  +     * @param str String to be manipulated
  +     *
  +     * @return Object result of operation upon passed String
  +     */
  +  public Object evaluateString(String str) throws JspException {
  +    return null;
  +  }
  +  
  +    /** 
  +     * Perform a transformation on the passed in String.
        *
        * @param str String to be manipulated
        *
  
  
  

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