jakarta-watchdog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sant...@locus.apache.org
Subject cvs commit: jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/tags/TagSupport SimpleIteratorTag.java defaultReturnValues.java firstPrizeTag.java secondPrizeTag.java
Date Thu, 30 Nov 2000 23:51:07 GMT
santosh     00/11/30 15:51:07

  Added:       src/server/jsp-tests/WEB-INF/classes/tags/TagSupport
                        SimpleIteratorTag.java defaultReturnValues.java
                        firstPrizeTag.java secondPrizeTag.java
  Log:
  Tests for TagSupport
  
  Revision  Changes    Path
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/tags/TagSupport/SimpleIteratorTag.java
  
  Index: SimpleIteratorTag.java
  ===================================================================
  //This is a Simple Iterator tag (JSP 1.2) 
  
  package tags;
  
  import javax.servlet.*;
  import javax.servlet.jsp.tagext.*;
  import javax.servlet.jsp.*;
  import java.io.IOException ;
  
  public class  SimpleIteratorTag extends TagSupport
  {
  //This tag prints "JSP is cool" Iteratively depending on the 
  //iteration attribute
  
  protected int number_of_iterations ;
  protected boolean callsetId = false;
  protected String tag_id ;
  
  public void setIteration(String num_iteration)
  {
  
  try
  {
  number_of_iterations= Integer.parseInt(num_iteration);
  }
  catch(NumberFormatException numex)
  {  number_of_iterations = 0; }
  
  }
  
  public void setSetget(String setget)
  {
  
  if( setget.equals("true") )
  callsetId=true;
  else
  callsetId=false ;
  
  }
  
  public void setTagid(String id)
  {
  if(id==null)
  tag_id="null" ;
  else
  tag_id = id;
  }
  
  public int doStartTag()
  {
  //Evaluate the body
  return Tag.EVAL_BODY_INCLUDE ;
  }
  
  public int doAfterBody()
  {
   try
   {
       if(number_of_iterations > 0)
       {
    		pageContext.getOut().println("JSP is cool");
    		number_of_iterations -- ;
    		return IterationTag.EVAL_BODY_AGAIN ;
       }
  
      if(callsetId)  //call the setId method
       {
      setId(tag_id);
      pageContext.getOut().println("My Tag Id is:" + getId() );
       }
  
  }catch(IOException ioe) { }
  
    return  Tag.SKIP_BODY ;
  }
  
  public int doEndTag()
  {
  try
  {
  pageContext.getOut().println("End of tag Reached");
  }catch(IOException ioe) { }
  return Tag.EVAL_PAGE ;
  }
  
  }
  
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/tags/TagSupport/defaultReturnValues.java
  
  Index: defaultReturnValues.java
  ===================================================================
  
  package tags.TagSupport;
  
  import javax.servlet.*;
  import javax.servlet.jsp.tagext.*;
  import javax.servlet.jsp.*;
  import java.io.IOException ;
  
  public class   defaultReturnValues extends TagSupport
  {
  //This tag tests for the default retun values from the TagSupport class
  //As mentioned in JSP spec
  
  
  public int doStartTag() throws JspException
  {
  //By default should return SKIP_BODY
   if( super.doStartTag() == Tag.SKIP_BODY)
    {
      try
       {
     	pageContext.getOut().println("doStartTag returned SKIP_BODY");
       }
      catch(IOException ioe) {  }
  
    }
  return  Tag.EVAL_BODY_INCLUDE  ;
  }
  
  public int doAfterBody() throws JspException
  {
    if( super.doAfterBody() == Tag.SKIP_BODY )
    {
       try
  	{
    		pageContext.getOut().println("doAfterBody returned SKIP_BODY");
    	}catch(IOException ioe) { }
    }
  
    return  Tag.SKIP_BODY ;
  }
  
  public int doEndTag() throws JspException
  {
  
  if( super.doEndTag() == Tag.EVAL_PAGE )
    {
       try
          {
                  pageContext.getOut().println("doEndTag returned EVAL_PAGE");
          }catch(IOException ioe) { }
    }
  
  return Tag.EVAL_PAGE ;
  }
  
  
  }
  
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/tags/TagSupport/firstPrizeTag.java
  
  Index: firstPrizeTag.java
  ===================================================================
  package tags.TagSupport;
  
  import javax.servlet.*;
  import javax.servlet.jsp.tagext.*;
  import javax.servlet.jsp.*;
  import java.io.IOException ;
  
  public class  firstPrizeTag extends TagSupport
  {
  //sets and returns the first prize winner
  
  protected String winner ;
  
  public void setWinner(String name) throws JspException
  {
   winner=name;
  }
  
  public String getWinner()
  {
  return winner; 
  }
  
  
  public int doStartTag()
  {
  try
  {
  if(winner!=null)
  pageContext.getOut().println("First Prize winner is : " + winner);
  }
  catch(IOException ioe) { }
  return Tag.EVAL_BODY_INCLUDE ;
  }
  
  
  }
  
  
  
  
  1.1                  jakarta-watchdog-4.0/src/server/jsp-tests/WEB-INF/classes/tags/TagSupport/secondPrizeTag.java
  
  Index: secondPrizeTag.java
  ===================================================================
  package tags.TagSupport;
  
  import javax.servlet.*;
  import javax.servlet.jsp.tagext.*;
  import javax.servlet.jsp.*;
  import java.io.IOException ;
  
  import tags.TagSupport.firstPrizeTag ;
  
  public class  secondPrizeTag extends TagSupport
  {
  //sets and returns the second prize winner
  
  protected String winner ;
  
  public void setWinner(String name) throws JspException
  {
  firstPrizeTag first = (firstPrizeTag)findAncestorWithClass(this,firstPrizeTag.class);
  
  if(first==null)
  throw new JspException("nesting error");
  
  String winner1 = first.getWinner();
   if(! winner1.equals(name) )
   winner=name;
  
  }
  
  public String getWinner()
  {
  return winner; 
  }
  
  
  public int doStartTag()
  {
  try
  {
  if(winner!=null)
  pageContext.getOut().println("Second Prize winner is : " + winner);
  }
  catch(IOException ioe) { }
  return Tag.EVAL_BODY_INCLUDE ;
  }
  
  
  }
  
  
  
  

Mime
View raw message