Apache Struts 2 Documentation > Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > UI Tag Reference > submit |
Please make sure you have read the Tag Syntax document and understand how tag attribute syntax works. |
Render a submit button. The submit tag is used together with the form tag to provide asynchronous form submissions. The submit can have three different types of rendering:
THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED
'errorText' is the text that will be displayed when there is an error making the request.
'onLoadJS' Deprecated. Use 'notifyTopics'.
'preInvokeJS' Deprecated. Use 'notifyTopics'.
'executeScripts' if set to true will execute javascript sections in the returned text.
'loadingText' is the text that will be displayed on the 'targets' elements while making the request.
'handler' is the name of the function that will take care of making the AJAX request. Dojo's widget and dom node are passed as parameters).
'formId' is the id of the html form whose fields will be seralized and passed as parameters in the request.
'formFilter' is the name of a function which will be used to filter the fields that will be seralized. This function takes as a parameter the element and returns true if the element should be included.
'listenTopics' comma separated list of topics names, that will trigger a request 'indicator' element to be shown while the request executing 'showErrorTransportText': whether errors should be displayed (on 'targets')
'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:
This tag works with all themes, but has special importance when combined with the form tag in the ajax theme. Please read up on the ajax theme for more information. |
Name |
Required |
Default |
Evaluated |
Type |
Description |
---|---|---|---|---|---|
accesskey | false | true | String | Set the html accesskey attribute on rendered html element | |
action | false | true | String | Set action attribute. | |
align | false | true | String | HTML align attribute. | |
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 | |
errorText | false | true | String | The text to display to the user if the is an error fetching the content | |
executeScripts | false | false | true | Boolean | Javascript code in the fetched content will be executed |
formFilter | false | true | String | Function name used to filter the fields of the form. | |
formId | false | true | String | Form id whose fields will be serialized and passed as parameters | |
handler | false | true | String | Javascript function name that will make the request | |
href | false | true | String | The URL to call to obtain the content. Note: If used with ajax context, the value must be set as an url tag value. | |
id | false | true | String | id for referencing element. For UI and form tags it will be used as HTML id attribute | |
indicator | false | true | String | Set indicator | |
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) | |
listenTopics | false | true | String | Topic that will trigger the remote call | |
loadingText | false | Loading... | true | String | Text to be shown while content is being fetched |
method | false | true | String | Set method attribute. | |
name | false | true | String | The name to set for element | |
notifyTopics | false | true | String | Topics that will published when the remote call completes | |
onLoadJS | false | true | String | Deprecated. Use 'notifyTopics'. Javascript code execute after reload | |
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 | |
preInvokeJS | false | true | String | Deprecated. Use 'notifyTopics'. Javascript code execute before reload | |
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) | |
showErrorTransportText | false | true | true | Boolean | Set whether errors will be shown or not |
src | false | true | String | Supply an image src for image type submit button. Will have no effect for types input and button. | |
tabindex | false | true | String | Set the html tabindex attribute on rendered html element | |
targets | false | true | String | Comma delimited list of ids of the elements whose content will be updated | |
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 to use for the element. This tag will usually use the ajax theme. | |
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 | |
type | false | input | true | String | The type of submit to use. Valid values are input, button and image. |
value | false | true | String | Preset the value of input element. |
<s:submit value="%{'Submit'}" />
Render an image submit:
<s:submit type="image" value="%{'Submit'}" label="Submit the form" src="submit.gif"/>
Render an button submit:
<s:submit type="button" value="%{'Submit'}" label="Submit the form"/>
Show the results in another div. If you want your results to be shown in a div, use the resultDivId where the id is the id of the div you want them shown in. This is an inner HTML approah. Your results get jammed into the div for you. Here is a sample of this approach:
Remote form replacing another div: <div id='two' style="border: 1px solid yellow;">Initial content</div> <s:form id='theForm2' cssStyle="border: 1px solid green;" action='/AjaxRemoteForm.action' method='post' theme="ajax"> <input type='text' name='data' value='Struts User' /> <s:submit value="GO2" theme="ajax" resultDivId="two" /> </s:form >