Apache Struts 2 Documentation > Home > Guides > Tag Developers Guide > Struts Tags > Tag Reference > UI Tag Reference > div |

Apache Struts 2 Documentation
div
Edit Page Browse Space Add Page Add News
Added by digi9ten, last edited by Don Brown on Jan 06, 2007 (view change)

## Description

The div tag when used on the ajax theme, provides a remote call from the current page to update a section of content without having to refresh the entire page.

It creates a HTML <DIV /> that obtains it's content via a remote XMLHttpRequest call via the dojo framework.

THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED

- href
- errorText
- afterLoading
- executeScripts
- loadingText
- listenTopics
- handler
- formId
- formFilter
- targets
- notifyTopics
- showErrorTransportText
- indicator

'targets' is a list of element ids whose content will be updated with the text returned from request.

'href' needs to be set as an url tag reference value.

'errorText' is the text that will be displayed when there is an error making the request.

'afterLoading' 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.

'updateFreq' sets(in milliseconds) the update interval. 'autoStart' if set to true(true by default) starts the timer automatically 'startTimerListenTopics' is a comma-separated list of topics used to start the timer 'stopTimerListenTopics' is a comma-separated list of topics used to stop the timer '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:

- data: html or json object when type='load' or type='error'
- type: 'before' before the request is made, 'load' when the request succeeds, or 'error' when it fails
- request: request javascript object, when type='load' or type='error'

| 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 div template documentation for more details.

## Parameters

#### Name | #### Required | #### Default | #### Evaluated | #### Type | #### Description
--- | --- | --- | --- | --- | ---
accesskey | false |  | true | String | Set the html accesskey attribute on rendered html element
afterLoading | false |  | true | String | Deprecated. Use 'notifyTopics'. Javascript code execute after reload
autoStart | false | true | true | Boolean | Start timer automatically
cssClass | false |  | true | String | The css class to use for element
cssStyle | false |  | true | String | The css style definitions for element ro use
delay | false |  | true | Integer | How long to wait before fetching the content (in milliseconds)
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
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.
refreshOnShow | false | false | true | Boolean | Content will be loaded when div becomes visible, used only inside tabbedPanel
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
startTimerListenTopics | false |  | true | String | Topics that will start the timer (for autoupdate)
stopTimerListenTopics | false |  | true | String | Topics that will stop the timer (for autoupdate)
tabindex | false |  | true | String | Set the html tabindex attribute on rendered html element
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
updateFreq | false |  | true | Integer | How often to reload the content (in milliseconds)
value | false |  | true | String | Preset the value of input element.

## Usage

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 div template.

| Handy Hint I have found that the target of the div must return good html. Basically a html and a body block that are happily closed.