All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.html.Form Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.html;

import com.hfg.html.attribute.EncType;

//------------------------------------------------------------------------------
/**
 * Represents a form (<form>) tag.
 *
 * @author J. Alex Taylor, hairyfatguy.com
 */
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------

public class Form extends HTMLTag
{

   //###########################################################################
   // PRIVATE FIELDS
   //###########################################################################


   //###########################################################################
   // CONSTRUCTORS
   //###########################################################################

   //--------------------------------------------------------------------------
   public Form()
   {
      super(HTML.FORM);
      setAction("");
   }

   //--------------------------------------------------------------------------
   public Form(String inFormName)
   {
      this();
      setName(inFormName);
   }

   //###########################################################################
   // PUBLIC METHODS
   //###########################################################################


   //--------------------------------------------------------------------------
   public InputButton addButton()
   {
      InputButton button = new InputButton();
      addSubtag(button);

      return button;
   }

   //--------------------------------------------------------------------------
   public InputButton addButton(String inName, String inValue)
   {
      InputButton button = new InputButton(inName, inValue);
      addSubtag(button);

      return button;
   }

   //--------------------------------------------------------------------------
   public InputCheckbox addCheckbox(String inName, String inValue)
   {
      InputCheckbox checkbox = new InputCheckbox(inName, inValue);
      addSubtag(checkbox);

      return checkbox;
   }

   //--------------------------------------------------------------------------
   public InputCheckbox addCheckbox(String inName, String inValue, boolean checked)
   {
      InputCheckbox checkbox = new InputCheckbox(inName, inValue, checked);
      addSubtag(checkbox);

      return checkbox;
   }


   //--------------------------------------------------------------------------
   public InputFile addFileInput()
   {
      InputFile subtag = new InputFile();
      addSubtag(subtag);

      return subtag;
   }

   //--------------------------------------------------------------------------
   public InputFile addFileInput(String inName)
   {
      InputFile subtag = new InputFile(inName);
      addSubtag(subtag);

      return subtag;
   }

   //--------------------------------------------------------------------------
   public InputFile addFileInput(String inName, String inValue)
   {
      InputFile subtag = new InputFile(inName, inValue);
      addSubtag(subtag);

      return subtag;
   }


   //--------------------------------------------------------------------------
   public InputHidden addHiddenInput(String inName, String inValue)
   {
      InputHidden hidden = new InputHidden(inName, inValue);
      addSubtag(hidden);

      return hidden;
   }

   //--------------------------------------------------------------------------
   public InputHidden addHiddenInput(String inName, Object inValue)
   {
      InputHidden hidden = new InputHidden(inName, inValue);
      addSubtag(hidden);

      return hidden;
   }

   //--------------------------------------------------------------------------
   public InputHidden addHiddenInput(String inName, int inValue)
   {
      InputHidden hidden = new InputHidden(inName, inValue);
      addSubtag(hidden);

      return hidden;
   }

   //--------------------------------------------------------------------------
   public InputHidden addHiddenInput(String inName, long inValue)
   {
      InputHidden hidden = new InputHidden(inName, inValue);
      addSubtag(hidden);

      return hidden;
   }

   //--------------------------------------------------------------------------
   public InputHidden addHiddenInput(String inName, float inValue)
   {
      InputHidden hidden = new InputHidden(inName, inValue);
      addSubtag(hidden);

      return hidden;
   }

   //--------------------------------------------------------------------------
   public InputHidden addHiddenInput(String inName, double inValue)
   {
      InputHidden hidden = new InputHidden(inName, inValue);
      addSubtag(hidden);

      return hidden;
   }


   //--------------------------------------------------------------------------
   public Label addLabel()
   {
      Label label = new Label();
      addSubtag(label);

      return label;
   }


   //--------------------------------------------------------------------------
   public Label addLabel(String inValue)
   {
      Label label = new Label(inValue);
      addSubtag(label);

      return label;
   }


   //--------------------------------------------------------------------------
   public InputPassword addPasswordInput()
   {
      InputPassword password = new InputPassword();
      addSubtag(password);

      return password;
   }

   //--------------------------------------------------------------------------
   public InputPassword addPasswordInput(String inName, String inValue)
   {
      InputPassword password = new InputPassword(inName, inValue);
      addSubtag(password);

      return password;
   }

   //--------------------------------------------------------------------------
   public InputRadio addRadio(String inName, String inValue)
   {
      InputRadio radio = new InputRadio(inName, inValue);
      addSubtag(radio);

      return radio;
   }

   //--------------------------------------------------------------------------
   public InputRadio addRadio(String inName, String inValue, boolean checked)
   {
      InputRadio radio = new InputRadio(inName, inValue, checked);
      addSubtag(radio);

      return radio;
   }

   //--------------------------------------------------------------------------
   public InputReset addReset()
   {
      InputReset reset = new InputReset();
      addSubtag(reset);

      return reset;
   }

   //--------------------------------------------------------------------------
   public Select addSelect(String inName)
   {
      Select select = new Select(inName);
      addSubtag(select);

      return select;
   }

   //--------------------------------------------------------------------------
   @Override
   public Form addStyle(String inValue)
   {
      return (Form) super.addStyle(inValue);
   }

   //--------------------------------------------------------------------------
   public InputSubmit addSubmit()
   {
      InputSubmit submit = new InputSubmit();
      addSubtag(submit);

      return submit;
   }

   //--------------------------------------------------------------------------
   public InputSubmit addSubmit(String inName, String inValue)
   {
      InputSubmit submit = new InputSubmit(inName, inValue);
      addSubtag(submit);

      return submit;
   }


   //--------------------------------------------------------------------------
   public Textarea addTextarea(String inName, String inValue)
   {
      Textarea textarea = new Textarea(inName, inValue);
      addSubtag(textarea);

      return textarea;
   }

   //--------------------------------------------------------------------------
   public Textarea addTextarea(String inName, String inValue, int inRows, int inCols)
   {
      Textarea textarea = new Textarea(inName, inValue, inRows, inCols);
      addSubtag(textarea);

      return textarea;
   }


   //--------------------------------------------------------------------------
   public InputText addTextInput()
   {
      InputText text = new InputText();
      addSubtag(text);

      return text;
   }

   //--------------------------------------------------------------------------
   public InputText addTextInput(String inName, String inValue)
   {
      InputText text = new InputText(inName, inValue);
      addSubtag(text);

      return text;
   }






   //--------------------------------------------------------------------------
   public Center addCenter()
   {
      Center center = new Center();
      addSubtag(center);

      return center;
   }

   //--------------------------------------------------------------------------
   public Center addCenter(String inContent)
   {
      Center center = new Center(inContent);
      addSubtag(center);

      return center;
   }

   //--------------------------------------------------------------------------
   public Center addCenter(HTMLTag inContent)
   {
      Center center = new Center(inContent);
      addSubtag(center);

      return center;
   }

   //--------------------------------------------------------------------------
   public Div addDiv()
   {
      Div subtag = new Div();
      addSubtag(subtag);

      return subtag;
   }

   //--------------------------------------------------------------------------
   public Div addDiv(HTMLTag inContent)
   {
      Div subtag = new Div(inContent);
      addSubtag(subtag);

      return subtag;
   }

   //--------------------------------------------------------------------------
   public Img addImage(String inSrc)
   {
      Img image = new Img(inSrc);
      addSubtag(image);

      return image;
   }

   //--------------------------------------------------------------------------
   public Link addLink()
   {
      Link link = new Link();
      addSubtag(link);

      return link;
   }

   //--------------------------------------------------------------------------
   public Link addLink(CharSequence inURL)
   {
      Link link = new Link(inURL);
      addSubtag(link);

      return link;
   }

   //--------------------------------------------------------------------------
   public Link addLink(CharSequence inURL, String inContent)
   {
      Link link = new Link(inURL, inContent);
      addSubtag(link);

      return link;
   }

   //--------------------------------------------------------------------------
   public Nobr addNobr()
   {
      Nobr nobr = new Nobr();
      addSubtag(nobr);

      return nobr;
   }

   //--------------------------------------------------------------------------
   public Nobr addNobr(String inContent)
   {
      Nobr nobr = new Nobr(inContent);
      addSubtag(nobr);

      return nobr;
   }

   //--------------------------------------------------------------------------
   public Nobr addNobr(HTMLTag inContent)
   {
      Nobr nobr = new Nobr(inContent);
      addSubtag(nobr);

      return nobr;
   }

   //--------------------------------------------------------------------------
   public Pre addPre()
   {
      Pre pre = new Pre();
      addSubtag(pre);

      return pre;
   }

   //--------------------------------------------------------------------------
   public Pre addPre(String inContent)
   {
      Pre pre = new Pre(inContent);
      addSubtag(pre);

      return pre;
   }

   //--------------------------------------------------------------------------
   public Pre addPre(HTMLTag inContent)
   {
      Pre pre = new Pre(inContent);
      addSubtag(pre);

      return pre;
   }

   //--------------------------------------------------------------------------
   public Span addSpan()
   {
      Span span = new Span();
      addSubtag(span);

      return span;
   }

   //--------------------------------------------------------------------------
   public Span addSpan(String inContent)
   {
      Span span = new Span(inContent);
      addSubtag(span);

      return span;
   }

   //--------------------------------------------------------------------------
   public Span addSpan(HTMLTag inContent)
   {
      Span span = new Span(inContent);
      addSubtag(span);

      return span;
   }

   //--------------------------------------------------------------------------
   public Table addTable()
   {
      Table table = new Table();
      addSubtag(table);

      return table;
   }

   //--------------------------------------------------------------------------
   public Ul addUnorderedList()
   {
      Ul ul = new Ul();
      addSubtag(ul);

      return ul;
   }



   //--------------------------------------------------------------------------
   public Form setName(String inValue)
   {
      setAttribute(HTML.NAME, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public String getName()
   {
      return getAttributeValue(HTML.NAME);
   }

   //--------------------------------------------------------------------------
   public Form setMethod(String inValue)
   {
      setAttribute(HTML.METHOD, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public String getMethod()
   {
      return getAttributeValue(HTML.METHOD);
   }

   //--------------------------------------------------------------------------
   public Form usePost()
   {
      setAttribute(HTML.METHOD, "post");

      return this;
   }

   //--------------------------------------------------------------------------
   public Form useGet()
   {
      setAttribute(HTML.METHOD, "get");

      return this;
   }

   //--------------------------------------------------------------------------
   public Form setAction(String inValue)
   {
      setAttribute(HTML.ACTION, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public String getAction()
   {
      return getAttributeValue(HTML.ACTION);
   }

   //--------------------------------------------------------------------------
   public Form setTarget(String inValue)
   {
      setAttribute(HTML.TARGET, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public String getTarget()
   {
      return getAttributeValue(HTML.TARGET);
   }

   //--------------------------------------------------------------------------
   public Form setId(String inValue)
   {
      setAttribute(HTML.ID, inValue);
      return this;
   }

   //--------------------------------------------------------------------------
   public Form setEnctype(String inValue)
   {
      setAttribute(HTML.ENCTYPE, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public Form useMultipartEncoding()
   {
      setAttribute(HTML.ENCTYPE, EncType.MULTIPART_FORM_DATA);

      return this;
   }

   //--------------------------------------------------------------------------
   public Form useUrlEncoding()
   {
      setAttribute(HTML.ENCTYPE, EncType.URL_ENCODED);

      return this;
   }

   //--------------------------------------------------------------------------
   public Form setOnSubmit(String inValue)
   {
      setAttribute(HTML.ONSUBMIT, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public String getOnSubmit()
   {
      return getAttributeValue(HTML.ONSUBMIT);
   }


   //--------------------------------------------------------------------------
   public Form setOnReset(String inValue)
   {
      setAttribute(HTML.ONRESET, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public void br()
   {
      HTMLUtil.br(this);
   }

   //--------------------------------------------------------------------------
   public void br(int inNumber)
   {
      HTMLUtil.br(this, inNumber);
   }

   //--------------------------------------------------------------------------
   public void nbsp(int inNumber)
   {
      HTMLUtil.nbsp(this, inNumber);
   }

   //--------------------------------------------------------------------------
   public void hr()
   {
      HTMLUtil.hr(this);
   }

   //--------------------------------------------------------------------------
   public void hr(String inWidth)
   {
      HTMLUtil.hr(this, inWidth);
   }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy