
// Copyright (c) 1999, 2000 Oracle Corporation
package oracle.jbo.html.jsp.datatags;

import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import oracle.jbo.*;
import oracle.jdeveloper.html.*;

public class RefreshDataSource extends TagSupport
{
  String sDataSource;

  public RefreshDataSource()
  {
  }

  public void setDatasource(String sDataSource)
  {
    this.sDataSource = sDataSource;
  }

   /**
     * Process the start tag for this instance.
     *
     * The doStartTag() method assumes that all setter methods have been
     * invoked before.
     *
     * When this method is invoked, the body has not yet been invoked.
     *
     * @returns EVAL_BODY_INCLUDE if the tag wants to process body, SKIP_BODY if it
     * does ont want to process it.
     */
  public int doStartTag() throws JspException
  {
    try
    {
      oracle.jdeveloper.html.DataWebBeanImpl ds = (oracle.jdeveloper.html.DataWebBeanImpl)pageContext.getAttribute(sDataSource);

      if(ds == null)
      {
        throw new Exception("Data Source was not found in page context.");
      }

      ds.getRowSet().executeQuery();
      
    }
    catch(Exception ex)
    {
      throw new JspException(ex.getMessage());
    }
    return Tag.EVAL_BODY_INCLUDE;
  }

  /**
  * release() called after doEndTag() to reset state
  */
  public void release()
  {
    this.sDataSource = null;
    super.release();
  }
}

 