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/02/27 06:08:54 UTC

cvs commit: jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib FileTag.java LocalesTag.java ResourceTag.java UsCustomerTag.java

felipeal    2004/02/26 21:08:54

  Modified:    standard/examples/src/org/apache/taglibs/standard/examples/taglib
                        Tag: STANDARD_1_0_BRANCH FileTag.java
                        LocalesTag.java ResourceTag.java UsCustomerTag.java
  Log:
  rolled back 1.0.5 changes
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.1   +18 -3     jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/FileTag.java
  
  Index: FileTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/FileTag.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- FileTag.java	27 Feb 2004 05:02:03 -0000	1.1
  +++ FileTag.java	27 Feb 2004 05:08:53 -0000	1.1.2.1
  @@ -61,6 +61,7 @@
   import javax.servlet.http.*;
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
  +import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
   
   import org.apache.taglibs.standard.examples.util.*;
   
  @@ -114,7 +115,7 @@
       // TagSupport methods
       
       public int doStartTag() throws JspException {
  -        reader = getReaderFromFile(file);
  +        reader = getReaderFromFile((String)eval("file", file, String.class));
           exposeVariable(reader);
           return EVAL_BODY_INCLUDE;
       }
  @@ -151,7 +152,21 @@
       
       //*********************************************************************
       // 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("file", attName);
  +        } else {
  +            return obj;
  +        }
  +    }
  +    
       private void exposeVariable(Reader reader) {
           if (id != null) {
               pageContext.setAttribute(id, reader);
  
  
  
  1.1.2.1   +20 -8     jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/LocalesTag.java
  
  Index: LocalesTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/LocalesTag.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- LocalesTag.java	27 Feb 2004 05:02:03 -0000	1.1
  +++ LocalesTag.java	27 Feb 2004 05:08:53 -0000	1.1.2.1
  @@ -59,6 +59,8 @@
   import javax.servlet.jsp.JspException;
   import javax.servlet.jsp.jstl.core.LoopTagSupport;
   
  +import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
  +
   /**
    * <p>Tag handler for &lt;locales&gt;
    *
  @@ -70,32 +72,42 @@
       private static final Locale[] locales = Locale.getAvailableLocales();
       private int pointer; 
       private String varTotal;
  +    private String endEL;
  +    private String beginEL;
   
       public void setVarTotal( String value ) {
   	varTotal = value;
       }
  -
       public void prepare() {
   	pointer = 0;
  +	try {
  +	    begin = ( (Integer) ExpressionEvaluatorManager.evaluate( "begin", beginEL, Integer.class,
  +								     this, super.pageContext )).intValue();
  +	    end = ( (Integer) ExpressionEvaluatorManager.evaluate( "end", endEL, Integer.class,
  +								   this, super.pageContext )).intValue();
  +	} catch( JspException exc ) {
  +	    System.err.println( "Exception evaluating  EL expressions: beginEL = " + beginEL +
  +				", endEL = " + endEL );
  +	    begin = end = -1;
  +	    exc.printStackTrace();
  +	}
   	if ( varTotal!=null && varTotal.length()>0 ) {
   	    pageContext.setAttribute( varTotal, new Integer(locales.length) );
   	}
       
       } 
  -
       public boolean hasNext() {
   	return pointer < locales.length;
       }  
  -
       public Object next() {
   	return locales[ pointer++ ];
       }
     
  -    public void setBegin( int value ) {
  -  	super.begin = value;
  +    public void setBegin( String value ) {
  +  	beginEL = value;
       }
     
  -    public void setEnd( int value ) {
  -  	super.end = value;
  +    public void setEnd( String value ) {
  +  	endEL = value;
       }                     
   }
  
  
  
  1.1.2.1   +18 -3     jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/ResourceTag.java
  
  Index: ResourceTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/ResourceTag.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- ResourceTag.java	27 Feb 2004 05:02:03 -0000	1.1
  +++ ResourceTag.java	27 Feb 2004 05:08:53 -0000	1.1.2.1
  @@ -61,6 +61,7 @@
   import javax.servlet.http.*;
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.tagext.*;
  +import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
   
   import org.apache.taglibs.standard.examples.util.*;
   
  @@ -114,7 +115,7 @@
       // TagSupport methods
       
       public int doStartTag() throws JspException {
  -        reader = getReaderFromResource(resource);
  +        reader = getReaderFromResource((String)eval("resource", resource, String.class));
           exposeVariable(reader);
           return EVAL_BODY_INCLUDE;
       }
  @@ -163,7 +164,21 @@
       
       //*********************************************************************
       // 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;
  +        }
  +    }
  +    
       private void exposeVariable(Reader reader) {
           if (id != null) {
               pageContext.setAttribute(id, reader);
  
  
  
  1.1.2.1   +32 -13    jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/UsCustomerTag.java
  
  Index: UsCustomerTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/examples/src/org/apache/taglibs/standard/examples/taglib/UsCustomerTag.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- UsCustomerTag.java	27 Feb 2004 05:02:03 -0000	1.1
  +++ UsCustomerTag.java	27 Feb 2004 05:08:53 -0000	1.1.2.1
  @@ -60,6 +60,7 @@
   import javax.servlet.jsp.jstl.core.*;
   
   import org.apache.taglibs.standard.examples.beans.Customer;
  +import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
   import org.apache.taglibs.standard.examples.util.*;
   
   /**
  @@ -74,7 +75,7 @@
       // Instance Variables
       
       /** Holds value of property customer. */
  -    private Customer customer;
  +    private String customer;
       
       //*********************************************************************
       // Constructor and lusCustomerecycle management
  @@ -100,16 +101,17 @@
       // ConditionalTagSupport methods
       
       protected boolean condition() throws JspTagException {
  -        try {
  -            if (customer == null) {
  -                throw new NullAttributeException("usCustomer", "test");
  -            } else {
  -                //System.out.println("country: " + customer.getAddress().getCountry());
  -                return (customer.getAddress().getCountry().equalsIgnoreCase("USA"));
  -            }
  +	try {
  +         Customer customerObj = (Customer)eval("customer", customer, Customer.class);
  +         if (customerObj == null) {
  +             throw new NullAttributeException("usCustomer", "test");
  +         } else {
  +             System.out.println("country: " + customerObj.getAddress().getCountry());
  +             return (customerObj.getAddress().getCountry().equalsIgnoreCase("USA"));
  +         }
           } catch (JspException ex) {
  -            throw new JspTagException(ex.toString());
  -        }
  +	 throw new JspTagException(ex.toString());
  +	}
       }
       
       //*********************************************************************
  @@ -119,7 +121,7 @@
        * Getter for property customer.
        * @return Value of property customer.
        */
  -    public Customer getCustomer() {
  +    public String getCustomer() {
           return customer;
       }
       
  @@ -127,7 +129,24 @@
        * Setter for property customer.
        * @param customer New value of property customer.
        */
  -    public void setCustomer(Customer customer) {
  +    public void setCustomer(String customer) {
           this.customer = customer;
  +    }
  +    
  +    //*********************************************************************
  +    // 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(attName, attValue);
  +        } else {
  +            return obj;
  +        }
       }
   }
  
  
  

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