Apache Struts 2 Documentation > Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > Generic Tag Reference > a |
A tag that creates a HTML <a href='' /> that when clicked calls a URL remote XMLHttpRequest call via the dojo framework.
THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED
'targets' is a list of element ids whose content will be updated with the text returned from request.
'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:
While this tag can be used with the simple theme, xhtml theme, and others, it is really designed to work best with the ajax theme. We recommend reading the ajax a template documentation for more details. |
Name |
Required |
Default |
Evaluated |
Type |
Description |
---|---|---|---|---|---|
accesskey | false | true | String | Set the html accesskey attribute on rendered html element | |
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 | Id of element that will be shown while making request | |
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 |
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 | |
openTemplate | false | true | String | Set template to use for opening the rendered html. | |
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 |
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 (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 | |
value | false | true | String | Preset the value of input element. |
To get started, use the head tag and the ajax theme. See ajax head template for more information. Then look at the usage details for the ajax a template.
If you want to use additional parameters in your s:a the best practice is to use a s:url to create your url and then leverage this url into your s:a tag. This is done by creating a s:url and specifying an id attribute.. like "testUrlId" in this example. Then in the s:a tag reference this id in the href attribute via " %{testUrlId}"
<s:url id="testUrlId" namespace="/subscriber" action="customField" method="delete"> <s:param name="customFieldDefinition.id" value="${id}"/> </s:url> <s:a errorText="Sorry your request had an error." preInvokeJS="confirm('Are you sure you want to delete this item?')" href="%{testUrlId}"> <img src="<s:url value="/images/delete.gif"/>" border="none"/></s:a> <img xsrc="<s:url value="/images/delete.gif"/>" border="none"/></s:a><img xsrc="<s:url value="/images/delete.gif"/>" border="none"/></s:a>