FileDocCategorySizeDatePackage
Div.javaAPI DocExample8440Mon Jul 23 13:26:36 BST 2007org.apache.struts2.components

Div

public class Div extends AbstractRemoteCallUIBean
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')

'showLoadingText' show loading text on targets

'separateScript' Run scripts in a separate scope, unique for each Div

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

Examples


<s:url id="url" action="AjaxTest" />
<s:div
id="once"
theme="ajax"
href="%{url}"
loadingText="Loading..."
listenTopics="/refresh"
updateFreq="3000"
autoStart="true"
formId="form"
></s:div>

Fields Summary
public static final String
TEMPLATE
public static final String
TEMPLATE_CLOSE
public static final String
COMPONENT_NAME
protected String
updateFreq
protected String
autoStart
protected String
delay
protected String
startTimerListenTopics
protected String
stopTimerListenTopics
protected String
refreshOnShow
protected String
separateScripts
Constructors Summary
public Div(com.opensymphony.xwork2.util.ValueStack stack, HttpServletRequest request, HttpServletResponse response)


           
        super(stack, request, response);
    
Methods Summary
public voidevaluateExtraParams()

        super.evaluateExtraParams();

        if (updateFreq != null)
            addParameter("updateFreq", findValue(updateFreq, Integer.class));
        if (autoStart != null)
            addParameter("autoStart", findValue(autoStart, Boolean.class));
        if (refreshOnShow != null)
            addParameter("refreshOnShow", findValue(refreshOnShow, Boolean.class));
        if (delay != null)
            addParameter("delay", findValue(delay, Integer.class));
        if (startTimerListenTopics != null)
            addParameter("startTimerListenTopics", findString(startTimerListenTopics));
        if (stopTimerListenTopics != null)
            addParameter("stopTimerListenTopics", findString(stopTimerListenTopics));
        if (separateScripts != null)
            addParameter("separateScripts", findValue(separateScripts, Boolean.class));
    
public java.lang.StringgetDefaultOpenTemplate()

        return TEMPLATE;
    
protected java.lang.StringgetDefaultTemplate()

        return TEMPLATE_CLOSE;
    
public voidsetAfterLoading(java.lang.String afterLoading)

        this.afterLoading = afterLoading;
    
public voidsetAutoStart(java.lang.String autoStart)

        this.autoStart = autoStart;
    
public voidsetDelay(java.lang.String delay)

        this.delay = delay;
    
public voidsetRefreshOnShow(java.lang.String refreshOnShow)

        this.refreshOnShow = refreshOnShow;
    
public voidsetSeparateScripts(java.lang.String separateScripts)

        this.separateScripts = separateScripts;
    
public voidsetStartTimerListenTopics(java.lang.String startTimerListenTopic)

        this.startTimerListenTopics = startTimerListenTopic;
    
public voidsetStopTimerListenTopics(java.lang.String stopTimerListenTopic)

        this.stopTimerListenTopics = stopTimerListenTopic;
    
public voidsetUpdateFreq(java.lang.String updateInterval)

        this.updateFreq = updateInterval;