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, IUrlParams, IAttributeConsumer, IHtmlAttrs, IHtmlCore, IHtmlEvents, IHtmlI18n, INetuiTag

public class Form
extends HtmlBaseTag
implements IUrlParams

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(
        forwards={
            @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 AbstractClassicTag
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT
 
Fields inherited from class BodyTagSupport
bodyContent
 
Fields inherited from class TagSupport
id, pageContext
 
Fields inherited from interface HtmlConstants
ABBR, ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, AREA, AXIS, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, BUTTON, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COLSPAN, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEADERS, 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, LANGUAGE, 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, ROWSPAN, RULES, SCOPE, SCRIPT, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TBODY, TD, TEXT, TEXTAREA, TFOOT, TH, THEAD, 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, String facet)
          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.
 String getAction()
          Return the action of the Form.
 String getLocation()
          Return the value of the location.
 String getRealFormId()
          This method will return the real id that will be written out by the form.
protected  AbstractHtmlState getState()
          This method will return the state associated with the tag.
 String getTagName()
          Return the name of the Tag.
 void insureRealId()
          This method will insure that a real id is written out even if a tagId is not set for the form.
 boolean isFocusSet()
          Get the focus flag.
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 setBeanName(String name)
          Set the attribute key under which our associated bean is stored.
 void setBeanScope(String scope)
          Sets the scope (request or session) under which the associated bean is stored.
 void setBeanType(String type)
          Sets the Java class name of the bean to be created, if necessary.
 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 setOnReset(String onReset)
          Sets the onReset javascript event.
 void setOnSubmit(String onSubmit)
          Sets the onSubmit javascript event.
 void setTarget(String target)
          Sets the window target.
 void setTargetScope(String targetScope)
          Set the target "scope" for the form's action.
 
Methods inherited from class HtmlBaseTag
getJavaScriptAttribute, getOnClick, getTagId, renderDefaultNameAndId, renderNameAndId, setDir, setLang, setOnClick, setOnDblClick, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setStateAttribute, setStyle, setStyleClass, setTagId, setTitle
 
Methods inherited from class AbstractClassicTag
applyNamingChain, getErrorsReport, getIdForTagId, getNamingChain, getNearestForm, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, 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.

getRealFormId

public String getRealFormId()
This method will return the real id that will be written out by the form. This is either the current state qualified tagId or the _realName if tagId is not specified.

Returns:
the value of the id attribute written by the form.

insureRealId

public void insureRealId()
This method will insure that a real id is written out even if a tagId is not set for the form.


setFocus

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

Parameters:
focus - the focus field name.

isFocusSet

public boolean isFocusSet()
Get the focus flag.

Returns:
true if the focus has been set. false otherwise.

setLocation

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

Parameters:
location - the location hash

getLocation

public String getLocation()
Return the value of the location.

Returns:
The value of the location.

setMethod

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

Parameters:
method - the request method
Throws:
JspException

setBeanName

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

Parameters:
name - the attribute key name
Throws:
JspException

setTargetScope

public void setTargetScope(String targetScope)
Set the target "scope" for the form's action. Multiple active page flows may exist concurrently within named scopes. This attribute selects which named scope to use. If omitted, the default scope is assumed.

Parameters:
targetScope - the name of the target scope in which the associated action's page flow resides.

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.

setBeanScope

public void setBeanScope(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.

setBeanType

public void setBeanType(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,
                         String facet)
                  throws JspException
Adds a URL parameter to the generated hyperlink.

Specified by:
addParameter in interface IUrlParams
Parameters:
name - the name of the parameter to be added.
value - the value of the parameter to be added (a String or String[]).
facet -
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.

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