org.apache.beehive.netui.tags.html
Class Form

Object
  extended by TagSupport
      extended by BodyTagSupport
          extended by AbstractClassicTag
              extended by HtmlBaseTag
                  extended by Form
All Implemented Interfaces:
Serializable, BodyTag, IterationTag, JspTag, Tag, HtmlConstants, URLParams, IAttributeConsumer, IHtmlAttrs, IHtmlCore, IHtmlEvents, IHtmlI18n, IHtmlIdWriter, INetuiTag

public class Form
extends HtmlBaseTag
implements URLParams, IHtmlIdWriter

This tag represents an input form, associated with a bean whose properties correspond to the various fields of the form.

See Also:
Serialized Form
Example
In this first sample, the <netui:form> tag invokes the processData action method in the Controller file when the form is submitted.
      <netui:form action="processData">
              Name:
              <netui:textBox dataSource="{actionForm.name}"/>
              Age:
              <netui:textBox dataSource="{actionForm.age}"/>
              <netui:button value="Submit" type="submit"/>
      </netui:form>

Notice that the processData action method takes a parameter of type ProcessDataForm.

    /**
     * @jpf:action
     * @jpf:forward name="success" path="showData.jsp"
     */
    protected Forward processData(ProcessDataForm form)
    {
        //
        // Process the submitted data here.
        //
      
        return new Forward("success");
    }

This means that the submitted data is loaded into an instance of ProcessDataForm before it is passed to the action method.

In this next sample, the form fields are pre-populated based upon default values stored in the Session object.

      <netui:form action="Action" type="corp.Controller$NameBean"
          scope="session" name="nameBean">
          Name: <netui:textBox dataSource="{actionForm.name}" />
          <netui:button value="Submit"/>
      </netui:form>

Field Summary
 
Fields inherited from class HtmlBaseTag
JAVASCRIPT_STATUS
 
Fields inherited from class AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface IHtmlIdWriter
ID_PARAMETER_NAME, ID_PREFIX, ID_REQUEST_ATTRIBUTE
 
Fields inherited from interface HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
Form()
           
 
Method Summary
 void addParameter(String name, Object value)
          Adds a URL parameter to the generated hyperlink.
 void addTagID(String tagID, String name)
          Adds a tagId and name to the Form's focusMap.
 int doAfterBody()
          Save the body content of the Form.
 int doEndTag()
          Render the end of this form.
 int doStartTag()
          Render the beginning of this form.
 void generateRealName()
           
 String getAction()
          Return the action of the Form.
 String getBeanName()
          Return the name of the form bean corresponding to this tag.
 String getNextId()
          Return the next id
 String getRealName()
          this is used to
protected  AbstractHtmlState getState()
          This method will return the state associated with the tag.
 String getTagName()
          Return the name of the Tag.
protected  void localRelease()
          Release any acquired resources.
 void setAction(String action)
          Set the name of the action for the Form.
 void setAttribute(String name, String value, String facet)
          Base support for the attribute tag.
 void setEnctype(String enctype)
          Set the content encoding to be used on a post submit.
 void setFocus(String focus)
          Set the name of the field to receive focus.
 void setGenJavaScriptFormSubmit(boolean formSubmit)
          Generate the JavaScript which will submit a form.
 void setLocation(String location)
          Set the location hash to append to the url.
 void setMethod(String method)
          Set the request method used when submitting this form.
 void setName(String name)
          Set the attribute key under which our associated bean is stored.
 void setOnReset(String onReset)
          Sets the onReset javascript event.
 void setOnSubmit(String onSubmit)
          Sets the onSubmit javascript event.
 void setScope(String scope)
          Sets the scope (request or session) under which the associated bean is stored.
 void setTarget(String target)
          Sets the window target.
 void setType(String type)
          Sets the Java class name of the bean to be created, if necessary.
 void writeId(String id, String expression)
          This method will add a id and expression to the map maintained by the implementor.
 
Methods inherited from class HtmlBaseTag
addTagIdMapping, getJavaScriptAttribute, getNearestForm, getNearestIdWriter, getOnClick, getTagId, isIdTransparency, qualifyUrlToContext, renderTagId, setDir, setLang, setOnClick, setOnDblClick, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setStateAttribute, setStyle, setStyleClass, setTagId, setTitle
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getNamingChain, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, renderAttribute, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write
 
Methods inherited from class BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Tag
getParent, setPageContext, setParent
 

Constructor Detail

Form

public Form()
Method Detail

getTagName

public String getTagName()
Return the name of the Tag.

Specified by:
getTagName in interface INetuiTag
Specified by:
getTagName in class AbstractClassicTag
Returns:
the name of the tag.

getState

protected AbstractHtmlState getState()
This method will return the state associated with the tag. This is used by this base class to access the individual state objects created by the tags.

Specified by:
getState in class HtmlBaseTag
Returns:
a subclass of the AbstractHtmlState class.

setAttribute

public void setAttribute(String name,
                         String value,
                         String facet)
                  throws JspException
Base support for the attribute tag. This is overridden to prevent setting the action, and method attributes.

Specified by:
setAttribute in interface IAttributeConsumer
Overrides:
setAttribute in class HtmlBaseTag
Parameters:
name - The name of the attribute. This value may not be null or the empty string.
value - The value of the attribute. This may contain an expression.
facet - The name of a facet to which the attribute will be applied. This is optional.
Throws:
JspException - A JspException may be thrown if there is an error setting the attribute.

getAction

public String getAction()
Return the action of the Form.

Returns:
a String representing the action name of the Form.

setAction

public void setAction(String action)
               throws JspException
Set the name of the action for the Form.

Parameters:
action - - the name of the action to set for the Form.
Throws:
JspException

setEnctype

public void setEnctype(String enctype)
Set the content encoding to be used on a post submit.

Parameters:
enctype - - the content encoding type.

getRealName

public String getRealName()
this is used to


generateRealName

public void generateRealName()

setFocus

public void setFocus(String focus)
Set the name of the field to receive focus.

Parameters:
focus - - the focus field name.

setLocation

public void setLocation(String location)
Set the location hash to append to the url.

Parameters:
location - - the location hash

setMethod

public void setMethod(String method)
               throws JspException
Set the request method used when submitting this form.

Parameters:
method - - the request method
Throws:
JspException

setName

public void setName(String name)
             throws JspException
Set the attribute key under which our associated bean is stored.

Parameters:
name - - the attribute key name
Throws:
JspException

setOnReset

public void setOnReset(String onReset)
Sets the onReset javascript event.

Parameters:
onReset - - the onReset event.

setOnSubmit

public void setOnSubmit(String onSubmit)
Sets the onSubmit javascript event.

Parameters:
onSubmit - - the onReset event.

setScope

public void setScope(String scope)
              throws JspException
Sets the scope (request or session) under which the associated bean is stored.

Parameters:
scope - - the scope.
Throws:
JspException

setTarget

public void setTarget(String target)
Sets the window target.

Parameters:
target - - the window target.

setType

public void setType(String type)
             throws JspException
Sets the Java class name of the bean to be created, if necessary.

Parameters:
type - - the class name
Throws:
JspException

setGenJavaScriptFormSubmit

public void setGenJavaScriptFormSubmit(boolean formSubmit)
Generate the JavaScript which will submit a form. This is usually generated if the form contains anchors that are used to submit the form. This will make sure the JavaScript is always generated.

Parameters:
formSubmit - boolean value indicating that the form submit JavaScript should be generated. Default is false.

addParameter

public void addParameter(String name,
                         Object value)
                  throws JspException
Adds a URL parameter to the generated hyperlink.

Specified by:
addParameter in interface URLParams
Parameters:
name - - the name of the parameter to be added.
value - - the value of the parameter to be added (a String or String[]).
Throws:
JspException

addTagID

public void addTagID(String tagID,
                     String name)
Adds a tagId and name to the Form's focusMap.

Parameters:
tagID - - the tagID of a child tag.
name - - the name of a child tag.

getBeanName

public String getBeanName()
Return the name of the form bean corresponding to this tag. There is no corresponding setter method; this method exists so that the nested tag classes can obtain the actual bean name derived from other attributes of the tag.


writeId

public void writeId(String id,
                    String expression)
This method will add a id and expression to the map maintained by the implementor. This map should be written to the form as a set of hidden fields that will contain the id.

Specified by:
writeId in interface IHtmlIdWriter
Parameters:
id -
expression -

getNextId

public String getNextId()
Return the next id

Specified by:
getNextId in interface IHtmlIdWriter

doStartTag

public int doStartTag()
               throws JspException
Render the beginning of this form.

Specified by:
doStartTag in interface Tag
Overrides:
doStartTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doAfterBody

public int doAfterBody()
                throws JspException
Save the body content of the Form.

Specified by:
doAfterBody in interface IterationTag
Overrides:
doAfterBody in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

doEndTag

public int doEndTag()
             throws JspException
Render the end of this form.

Specified by:
doEndTag in interface Tag
Overrides:
doEndTag in class BodyTagSupport
Throws:
JspException - if a JSP exception has occurred

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class HtmlBaseTag