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 Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Wrap field validator, add visitor's field prefix to the field name. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected String
protected ActionValidatorManager
protected Configuration
protected String
protected String
protected boolean
protected String
protected String
protected ObjectFactory
protected String
protected String
static final String
protected String
protected String
static final String
protected UrlRenderer
protected String
protected String
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
ConstructorsConstructorDescriptionForm
(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
evaluateClientSideJsEnablement
(String actionName, String namespace, String actionMethod) Evaluate client side JavaScript Enablement.protected void
protected boolean
protected String
A contract that requires each concrete UI Tag to specify which template should be used as a default.protected int
Get a incrementing sequence unique to thisForm
component.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
void
void
setConfiguration
(Configuration configuration) void
setEnctype
(String enctype) void
setFocusElement
(String focusElement) void
setIncludeContext
(boolean includeContext) void
void
setNamespace
(String namespace) void
setObjectFactory
(ObjectFactory objectFactory) void
setOnreset
(String onreset) void
setOnsubmit
(String onsubmit) void
setPortletMode
(String portletMode) void
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
-
Field Details
-
OPEN_TEMPLATE
- See Also:
-
TEMPLATE
- See Also:
-
onsubmit
-
onreset
-
action
-
target
-
enctype
-
method
-
namespace
-
validate
-
portletMode
-
windowState
-
acceptcharset
-
includeContext
protected boolean includeContext -
focusElement
-
configuration
-
objectFactory
-
urlRenderer
-
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 classUIBean
-
getDefaultOpenTemplate
- Specified by:
getDefaultOpenTemplate
in classClosingUIBean
-
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 classUIBean
- Returns:
- The name of the template to be used as the default.
-
setConfiguration
-
setObjectFactory
-
setUrlRenderer
-
setActionValidatorManager
-
evaluateExtraParams
protected void evaluateExtraParams()- Overrides:
evaluateExtraParams
in classUIBean
-
populateComponentHtmlId
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.
- Overrides:
populateComponentHtmlId
in classUIBean
- 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 fornamespace
- the namespace to check foractionMethod
- the method to ckeck for
-
getValidators
-
getVisitorReturnType
Return type of visited object.- Parameters:
actionClass
- action classvisitorFieldName
- field name- Returns:
- type of visited object
-
getSequence
protected int getSequence()Get a incrementing sequence unique to thisForm
component. It is used byForm
component'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
-
setIncludeContext
public void setIncludeContext(boolean includeContext)
-