You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 50 Next »

Struts 2.0 versus Struts 2.1 and the Dojo tags

The easiest way to get documentation for Struts 2.0 Dojo tag usage is to look at older Struts 2 documentation, like the Struts 2.0.11 Ajax tags wiki documentation.

Please check that documentation and the Dojo tag examples in the showcase app of the appropriate Struts 2 version before asking questions on the struts-user mailing list!


THE WIKI IS NOT VERSIONABLE (in a practical way).

The documentation here is for the most current Struts 2, not necessarily the most current release. We try to add version-specific documentation notes but have undoubtedly missed some locations.

Description

To use the AJAX tags from 2.1 on you must:

  • Include the Dojo Plugin distributed with Struts 2 in your /WEB-INF/lib folder.
  • Add <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> to your page.
  • Include the head tag on the page, which can be configured for performance or debugging purposes.

Handling AJAX Responses

The following attributes affect the handling of all ajax responses.

Attribute

Default Value

Description

parseContent

true

When true, Dojo will parse the response into an XHTML Document Object and traverse the nodes searching for Dojo Widget markup. The parse and traversal is performed prior to inserting the nodes into the DOM. This attribute must be enabled to nest Dojo widgets (dojo tags) within responses. Note that there is significant performance overhead creating and parsing the document so switch this feature off when not required. Note also that the response must be valid XHTML for cross-browser support.

separateScripts

true

When true, Dojo will extract the <script> tags from the response, concatenate the extracted code into one block, create a new Function whose body is the extracted code and immediately invoke the function. The invocation is performed after the DOM has been updated with the XHTML. The function is executed within the scope of the widget (that is, the this variable points to the widget instance)

executeScripts

false

When true, Dojo will extract the <script> tags from the response, concatenate the extracted code into one block and immediately perform an eval() on that code (run it). The eval() is performed after the DOM has been updated. Note that the separateScripts takes precedence over executeScripts. Enable this feature when your response contains TRUSTED inline javascript.

It's common that the updated DOM will not include <script> even though the inline code may have been executed.

Topics

Most of the AJAX tags use Dojo topics for event notification and communication between them, to learn about topics visit Dojo's documentation

Examples

Examples can be found on the documentation for each tag in the UI Tag Reference page, for additional examples see Ajax and JavaScript Recipes and the Showcase application distributed with Struts 2.

Tags

  • No labels