/********************************************************************
 *  Oracle JDeveloper
 *  Copyright (c) 1997, 1999, Oracle Corporation. All rights reserved.
 ********************************************************************/


package oracle.jdeveloper.html;

import java.io.PrintWriter;
import java.util.Vector;

/**
 *
 * This represents a FORM's field. You can construct variations on this object by passing
 * different HTMLElement classes for the label and the element. The label will show up to the left of
 * the element when rendered inside the HTML FORM.
 *
 * @author  Juan Oropeza
 * @version PUBLIC
 *
 **/
public class HTMLFormField extends HTMLTableCell
{
   protected   HTMLElement Label;
   protected   boolean     useLabel = true;
   
   /**
   *	Constructor providing a label and an element. The label will be used.
   */
   public HTMLFormField(HTMLElement Label , HTMLElement Element)
   {
      super(Element);
      this.Label =  Label;
      this.Element = Element;
   }


   /**
   *	Constructor providing a label, element and a boolean that controls wether to use the label or not.
   */
   public HTMLFormField(HTMLElement Label , HTMLElement Element, boolean     useLabel)
   {
      super(Element);
      this.Label =  Label;
      this.Element = Element;
      this.useLabel = useLabel;
   }
   
   public void render(PrintWriter out) throws Exception
   {

      if(useLabel && Label != null)
      {
         out.println("<TD CLASS=\"vrFormLabel\" >");
         Label.render(out);
         out.println("</TD>");
      }

      if(useLabel && Label == null)
      {
         out.println("<TD CLASS=\"vrFormLabel\" >&nbsp;</TD>");
      }
      
      super.render(out);

   }
         
}