/*
 * @(#)RollbackTag.java
 *
 * Copyright 2000-2002 by Oracle Corporation,
 * 500 Oracle Parkway, Redwood Shores, California, 94065, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Oracle Corporation.
 */

package oracle.jbo.html.jsp.datatags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;
import oracle.jbo.ApplicationModule;
import oracle.jbo.common.ampool.ApplicationModuleRef;

public class RollbackTag extends TagSupport
{
   protected String amId;

   public void setAppid(String amId)
   {
      this.amId = amId;
   }

   /**
   * 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
   {
      ApplicationModuleRef amRef = Utils.getAMRefFromContext(pageContext, amId);
      ApplicationModule am = amRef.useApplicationModule();
      am.getTransaction().rollback();
      
      return Tag.EVAL_BODY_INCLUDE;
   }

   /**
   * release() called after doEndTag() to reset state
   */
   public void release()
   {
      super.release();

      amId = null;
   }
}
