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
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:
 
- If the action attribute is not specified, then the current request will be used to determine the posting url
- 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.
- 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 SummaryNested ClassesModifier and TypeClassDescriptionstatic classWrap field validator, add visitor's field prefix to the field name.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected ActionValidatorManagerprotected Configurationprotected Stringprotected Stringprotected booleanprotected Stringprotected Stringprotected ObjectFactoryprotected Stringprotected Stringstatic final Stringprotected Stringprotected Stringstatic final Stringprotected UrlRendererprotected Stringprotected StringFields inherited from class org.apache.struts2.components.UIBeanaccesskey, 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, valueFields inherited from class org.apache.struts2.components.ComponentactionMapper, attributes, COMPONENT_STACK, devMode, escapeHtmlBody, performClearTagStateForTagPoolingServers, stack, standardAttributesMap, throwExceptionOnELFailure
- 
Constructor SummaryConstructorsConstructorDescriptionForm(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidevaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod) Evaluate client side JavaScript Enablement.protected voidprotected booleanprotected StringA contract that requires each concrete UI Tag to specify which template should be used as a default.protected intGet a incrementing sequence unique to thisFormcomponent.getValidators(String name) protected ClassgetVisitorReturnType(Class actionClass, String visitorFieldName) Return type of visited object.protected voidpopulateComponentHtmlId(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.voidsetAcceptcharset(String acceptcharset) voidvoidvoidsetConfiguration(Configuration configuration) voidsetEnctype(String enctype) voidsetFocusElement(String focusElement) voidsetIncludeContext(boolean includeContext) voidvoidsetNamespace(String namespace) voidsetObjectFactory(ObjectFactory objectFactory) voidsetOnreset(String onreset) voidsetOnsubmit(String onsubmit) voidsetPortletMode(String portletMode) voidvoidsetUrlRenderer(UrlRenderer urlRenderer) voidsetValidate(String validate) voidsetWindowState(String windowState) Methods inherited from class org.apache.struts2.components.ClosingUIBeansetOpenTemplate, startMethods inherited from class org.apache.struts2.components.UIBeanaddFormParameter, 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, setValueMethods inherited from class org.apache.struts2.components.ComponentaddAllAttributes, 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
- 
Field Details- 
OPEN_TEMPLATE- See Also:
 
- 
TEMPLATE- See Also:
 
- 
onsubmit
- 
onreset
- 
action
- 
target
- 
enctype
- 
method
- 
namespace
- 
validate
- 
portletMode
- 
windowState
- 
acceptcharset
- 
includeContextprotected boolean includeContext
- 
focusElement
- 
configuration
- 
objectFactory
- 
urlRenderer
- 
actionValidatorManager
 
- 
- 
Constructor Details- 
Formpublic Form(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) 
 
- 
- 
Method Details- 
evaluateNameValueprotected boolean evaluateNameValue()- Overrides:
- evaluateNameValuein class- UIBean
 
- 
getDefaultOpenTemplate- Specified by:
- getDefaultOpenTemplatein class- ClosingUIBean
 
- 
getDefaultTemplateDescription copied from class:UIBeanA 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:
- getDefaultTemplatein class- UIBean
- Returns:
- The name of the template to be used as the default.
 
- 
setConfiguration
- 
setObjectFactory
- 
setUrlRenderer
- 
setActionValidatorManager
- 
evaluateExtraParamsprotected void evaluateExtraParams()- Overrides:
- evaluateExtraParamsin class- UIBean
 
- 
populateComponentHtmlIdForm 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.
 - Overrides:
- populateComponentHtmlIdin class- UIBean
- Parameters:
- form- enclosing form tag
 
- 
evaluateClientSideJsEnablementprotected 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
- 
getVisitorReturnTypeReturn type of visited object.- Parameters:
- actionClass- action class
- visitorFieldName- field name
- Returns:
- type of visited object
 
- 
getSequenceprotected int getSequence()Get a incrementing sequence unique to thisFormcomponent. It is used byFormcomponent's child that might need a sequence to make them unique.- Returns:
- int
 
- 
setOnsubmit
- 
setOnreset
- 
setAction
- 
setTarget
- 
setEnctype
- 
setMethod
- 
setNamespace
- 
setValidate
- 
setPortletMode
- 
setWindowState
- 
setAcceptcharset
- 
setFocusElement
- 
setIncludeContextpublic void setIncludeContext(boolean includeContext) 
 
-