Package org.apache.struts2.components

# Class Form

java.lang.Object
org.apache.struts2.components.Component
org.apache.struts2.components.UIBean
org.apache.struts2.components.ClosingUIBean
org.apache.struts2.components.Form

public class Form extends ClosingUIBean

Renders HTML an input form.

The remote form allows the form to be submitted without the page being refreshed. The results from the form can be inserted into any HTML element on the page.

NOTE:
The order / logic in determining the posting url of the generated HTML form is as follows:

1. If the action attribute is not specified, then the current request will be used to determine the posting url
2. If the action is given, Struts will try to obtain an ActionConfig. This will be successful if the action attribute is a valid action alias defined struts.xml.
3. If the action is given and is not an action alias defined in struts.xml, Struts will used the action attribute as if it is the posting url, separting the namespace from it and using UrlHelper to generate the final url.

Examples

     <s:form ... />

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `Form.FieldVisitorValidatorWrapper`
  Wrap field validator, add visitor's field prefix to the field name.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected String`
  `acceptcharset`
  `protected String`
  `action`
  `protected ActionValidatorManager`
  `actionValidatorManager`
  `protected Configuration`
  `configuration`
  `protected String`
  `enctype`
  `protected String`
  `focusElement`
  `protected boolean`
  `includeContext`
  `protected String`
  `method`
  `protected String`
  `namespace`
  `protected ObjectFactory`
  `objectFactory`
  `protected String`
  `onreset`
  `protected String`
  `onsubmit`
  `static final String`
  `OPEN_TEMPLATE`
  `protected String`
  `portletMode`
  `protected String`
  `target`
  `static final String`
  `TEMPLATE`
  `protected UrlRenderer`
  `urlRenderer`
  `protected String`
  `validate`
  `protected String`
  `windowState`

  ### Fields inherited from class org.apache.struts2.components.UIBean

  `accesskey, ATTR_FIELD_VALUE, ATTR_NAME_VALUE, ATTR_VALUE, cssClass, cssErrorClass, cssErrorStyle, cssStyle, defaultTemplateDir, defaultUITheme, disabled, dynamicAttributes, errorPosition, id, javascriptTooltip, key, label, labelPosition, labelSeparator, name, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, request, requiredLabel, requiredPosition, response, tabindex, template, templateDir, templateEngineManager, templateSuffix, theme, title, tooltip, tooltipConfig, tooltipCssClass, tooltipDelay, tooltipIconPath, uiStaticContentPath, uiThemeExpansionToken, value`

  ### Fields inherited from class org.apache.struts2.components.Component

  `actionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Form(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod)`
  Evaluate client side JavaScript Enablement.
  `protected void`
  `evaluateExtraParams()`
  `protected boolean`
  `evaluateNameValue()`
  `String`
  `getDefaultOpenTemplate()`
  `protected String`
  `getDefaultTemplate()`
  A contract that requires each concrete UI Tag to specify which template should be used as a default.
  `protected int`
  `getSequence()`
  Get a incrementing sequence unique to this `Form` component.
  `List`
  `getValidators(String name)`
  `protected Class`
  `getVisitorReturnType(Class actionClass, String visitorFieldName)`
  Return type of visited object.
  `protected void`
  `populateComponentHtmlId(Form form)`
  Form component determine the its HTML element id as follows:- if an 'id' attribute is specified. if an 'action' attribute is specified, it will be used as the id.
  `void`
  `setAcceptcharset(String acceptcharset)`
  `void`
  `setAction(String action)`
  `void`
  `setActionValidatorManager(ActionValidatorManager mgr)`
  `void`
  `setConfiguration(Configuration configuration)`
  `void`
  `setEnctype(String enctype)`
  `void`
  `setFocusElement(String focusElement)`
  `void`
  `setIncludeContext(boolean includeContext)`
  `void`
  `setMethod(String method)`
  `void`
  `setNamespace(String namespace)`
  `void`
  `setObjectFactory(ObjectFactory objectFactory)`
  `void`
  `setOnreset(String onreset)`
  `void`
  `setOnsubmit(String onsubmit)`
  `void`
  `setPortletMode(String portletMode)`
  `void`
  `setTarget(String target)`
  `void`
  `setUrlRenderer(UrlRenderer urlRenderer)`
  `void`
  `setValidate(String validate)`
  `void`
  `setWindowState(String windowState)`

  ### Methods inherited from class org.apache.struts2.components.ClosingUIBean

  `setOpenTemplate, start`

  ### Methods inherited from class org.apache.struts2.components.UIBean

  `addFormParameter, applyValueParameter, buildTemplateName, copyAttributes, enableAncestorFormCustomOnsubmit, end, ensureAttributeSafelyNotEscaped, escape, evaluateParams, getId, getTemplate, getTemplateDir, getTheme, getTooltipConfig, getValueClassType, lazyEvaluation, mergeTemplate, setAccesskey, setCssClass, setCssErrorClass, setCssErrorStyle, setCssStyle, setDefaultTemplateDir, setDefaultUITheme, setDisabled, setDynamicAttributes, setErrorPosition, setId, setJavascriptTooltip, setKey, setLabel, setLabelPosition, setLabelSeparator, setName, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setRequiredLabel, setRequiredPosition, setStaticContentPath, setStyle, setTabindex, setTemplate, setTemplateDir, setTemplateEngineManager, setTheme, setTitle, setTooltip, setTooltipConfig, setTooltipCssClass, setTooltipDelay, setTooltipIconPath, setUIThemeExpansionToken, setValue`

  ### Methods inherited from class org.apache.struts2.components.Component

  `addAllAttributes, addParameter, completeExpression, determineActionURL, determineNamespace, end, escapeHtmlBody, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getAttributes, getComponentStack, getNamespace, getPerformClearTagStateForTagPoolingServers, getStack, getStandardAttributes, isAcceptableExpression, isValidTagAttribute, popComponentStack, setActionMapper, setDevMode, setEscapeHtmlBody, setNotExcludedAcceptedPatterns, setPerformClearTagStateForTagPoolingServers, setThrowExceptionsOnELFailure, setUrlHelper, stripExpression, toString, usesBody`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### OPEN_TEMPLATE

    public static final String OPEN_TEMPLATE
    See Also:
      - Constant Field Values

  - ### TEMPLATE

    public static final String TEMPLATE
    See Also:
      - Constant Field Values

  - ### onsubmit

    protected String onsubmit

  - ### onreset

    protected String onreset

  - ### action

    protected String action

  - ### target

    protected String target

  - ### enctype

    protected String enctype

  - ### method

    protected String method

  - ### namespace

    protected String namespace

  - ### validate

    protected String validate

  - ### portletMode

    protected String portletMode

  - ### windowState

    protected String windowState

  - ### acceptcharset

    protected String acceptcharset

  - ### includeContext

    protected boolean includeContext

  - ### focusElement

    protected String focusElement

  - ### configuration

    protected Configuration configuration

  - ### objectFactory

    protected ObjectFactory objectFactory

  - ### urlRenderer

    protected UrlRenderer urlRenderer

  - ### actionValidatorManager

    protected ActionValidatorManager actionValidatorManager

- ## Constructor Details

  - ### Form

    public Form(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)

- ## Method Details

  - ### evaluateNameValue

    protected boolean evaluateNameValue()
    Overrides:
      `evaluateNameValue` in class `UIBean`

  - ### getDefaultOpenTemplate

    public String getDefaultOpenTemplate()
    Specified by:
      `getDefaultOpenTemplate` in class `ClosingUIBean`

  - ### getDefaultTemplate

    protected String getDefaultTemplate()
    Description copied from class: `UIBean`
    A contract that requires each concrete UI Tag to specify which template should be used as a default. For example, the CheckboxTab might return "checkbox.vm" while the RadioTag might return "radio.vm". This value not begin with a '/' unless you intend to make the path absolute rather than relative to the current theme.
    Specified by:
      `getDefaultTemplate` in class `UIBean`
    Returns:
      The name of the template to be used as the default.

  - ### setConfiguration

    public void setConfiguration(Configuration configuration)

  - ### setObjectFactory

    public void setObjectFactory(ObjectFactory objectFactory)

  - ### setUrlRenderer

    public void setUrlRenderer(UrlRenderer urlRenderer)

  - ### setActionValidatorManager

    public void setActionValidatorManager(ActionValidatorManager mgr)

  - ### evaluateExtraParams

    protected void evaluateExtraParams()
    Overrides:
      `evaluateExtraParams` in class `UIBean`

  - ### populateComponentHtmlId

    protected void populateComponentHtmlId(Form form)
    Form component determine the its HTML element id as follows:-
    1. if an 'id' attribute is specified.
    2. if an 'action' attribute is specified, it will be used as the id.
    Overrides:
      `populateComponentHtmlId` in class `UIBean`
    Parameters:
      `form` - enclosing form tag

  - ### evaluateClientSideJsEnablement

    protected void evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod)
    Evaluate client side JavaScript Enablement.
    Parameters:
      `actionName` - the actioName to check for
      `namespace` - the namespace to check for
      `actionMethod` - the method to ckeck for

  - ### getValidators

    public List getValidators(String name)

  - ### getVisitorReturnType

    protected Class getVisitorReturnType(Class actionClass, String visitorFieldName)
    Return type of visited object.
    Parameters:
      `actionClass` - action class
      `visitorFieldName` - field name
    Returns:
      type of visited object

  - ### getSequence

    protected int getSequence()
    Get a incrementing sequence unique to this `Form` component. It is used by `Form` component's child that might need a sequence to make them unique.
    Returns:
      int

  - ### setOnsubmit

    public void setOnsubmit(String onsubmit)

  - ### setOnreset

    public void setOnreset(String onreset)

  - ### setAction

    public void setAction(String action)

  - ### setTarget

    public void setTarget(String target)

  - ### setEnctype

    public void setEnctype(String enctype)

  - ### setMethod

    public void setMethod(String method)

  - ### setNamespace

    public void setNamespace(String namespace)

  - ### setValidate

    public void setValidate(String validate)

  - ### setPortletMode

    public void setPortletMode(String portletMode)

  - ### setWindowState

    public void setWindowState(String windowState)

  - ### setAcceptcharset

    public void setAcceptcharset(String acceptcharset)

  - ### setFocusElement

    public void setFocusElement(String focusElement)

  - ### setIncludeContext

    public void setIncludeContext(boolean includeContext)