Apache Struts 2 Documentation > Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > UI Tag Reference > form
Added by Patrick Lightbody, last edited by Don Brown on Jan 06, 2007  (view change)
Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works.

Description

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 successfull 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.

Parameters

Name

Required

Default

Evaluated

Type

Description

acceptcharset false true String The accepted charsets for this form. The values may be comma or blank delimited.
accesskey false true String Set the html accesskey attribute on rendered html element
action false current action true String Set action nane to submit to, without .action suffix
cssClass false true String The css class to use for element
cssStyle false true String The css style definitions for element ro use
disabled false true String Set the html disabled attribute on rendered html element
enctype false true String HTML form enctype attribute
id false true String id for referencing element. For UI and form tags it will be used as HTML id attribute
key false true String Set the key (name, value, label) for this particular component
label false true String Label expression used for rendering a element specific label
labelposition false true String Define label position of form element (top/left)
method false true String HTML form method attribute
name false true String The name to set for element
namespace false current namespace true String Namespace for action to submit to
onblur false true String Set the html onblur attribute on rendered html element
onchange false true String Set the html onchange attribute on rendered html element
onclick false true String Set the html onclick attribute on rendered html element
ondblclick false true String Set the html ondblclick attribute on rendered html element
onfocus false true String Set the html onfocus attribute on rendered html element
onkeydown false true String Set the html onkeydown attribute on rendered html element
onkeypress false true String Set the html onkeypress attribute on rendered html element
onkeyup false true String Set the html onkeyup attribute on rendered html element
onmousedown false true String Set the html onmousedown attribute on rendered html element
onmousemove false true String Set the html onmousemove attribute on rendered html element
onmouseout false true String Set the html onmouseout attribute on rendered html element
onmouseover false true String Set the html onmouseover attribute on rendered html element
onmouseup false true String Set the html onmouseup attribute on rendered html element
onselect false true String Set the html onselect attribute on rendered html element
onsubmit false true String HTML onsubmit attribute
openTemplate false true String Set template to use for opening the rendered html.
portletMode false true String he portlet mode to display after the form submit
required false false true Boolean If set to true, the rendered element will indicate that input is required
requiredposition false true String Define required position of required form element (left|right)
tabindex false true String Set the html tabindex attribute on rendered html element
target false true String HTML form target attribute
template false true String The template (other than default) to use for rendering the element
templateDir false true String The template directory.
theme false true String The theme (other than default) to use for rendering the element
title false true String Set the html title attribute on rendered html element
tooltip false true String Set the tooltip of this particular component
tooltipConfig false true String Set the tooltip configuration
validate false false true Boolean Whether client side/remote validation should be performed. Only useful with theme xhtml/ajax
value false true String Preset the value of input element.
windowState false true String The window state to display after the form submit

Examples

<p/>
<s:form ... />
<p/>

Validation

There are two flavours Client Side Validation, depening on the theme you are using (xhtml, ajax, etc). If you are using the xhtml theme or css_xhtml theme, pure client side validation will be used. If you are using the ajax theme, a special AJAX-based validation will take place. Read the Client Side Validation docs for more information.