Home > Guides > Tag Developers Guide > Struts Tags > Ajax Tags > Ajax and JavaScript Recipes

Dojo plugin is deprecated

Icon

The Dojo plugin will be deprecated on Struts 2.1

Common

All examples on this page assume the following JSP fragment is on the same page as the example.

Requests

Request is triggered by a topic
Attached to an event
Attached to an event on multiple sources
Attached to multiple events on multiple sources
Update target element with content returned from url
Update multiple target elements with content returned from url
Show indicator while request is in progress
Highlight content of target with blue color, for 2 seconds
Execute JavaScript in the returned content
Publish a topic before the request
Publish a topic after the request
Publish a topic on error
Show a fixed error message on error
Prevent a request
Submit a form (plain form)
Submit a form (using s:form tag)

Div

Loads its content after page is loaded
Reloads content when topic is published
Updates its content every 2 seconds, shows indicator while loading content
Loads its content after a delay of 2 seconds
Show some text while content is loaded
Fixed error message
Execute JavaScript in the returned content
Control refresh timer using topics

Date and Time picker

Date picker
Time picker
Set value from an String
Set value from stack (value must evaluate to either a Date, Calendar, or an String that can be parsed using the formats defined in SimpleDateFormat, and RFC 3339)
Set/Get value using JavaScript
Style the textbox
Publish topic when value changes
Use other locales.
Icon

Locales must be specified in the sx:head tag.

Tabbed Panel

Local Tabs
Local and remote tabs
Fixed size (size does not adjust to current tab)
Do not load tab 2 when page loads (it will be loaded when selected)
Reload tabs content when selected
Disabled tabs
Enable/Disable tabs using JavaScript
Set Tab labels position to bottom (can be: top, right, bottom, left)
Allow tab 2 to be removed(closed)
Publish topics when tab is selected
Select tab using JavaScript
Prevent tab 2 from being selected
Customize template css path (Dojo widget template css)

Autocompleter

Fixed list
Set initial value
Force valid option (restore option when focus is lost)
Using the JSON plugin to generate the values (one of the possible ways)

The action

AutocompleterExample.java

The mapping:

struts.xml

The JSP (fragment):

Example action

When a form containing an autocompleter is submitted, two values will be submitted for each autocompleter, one for the selected value, and one for its associated key.

The action:

MyAction.java

The JSP:

Set initial key and value
Change default key name

The action:

MyAction.java

The JSP:

JSON accepted

for this autocompleter:

The following JSON will be accepted:

Map(recommended as it is the easiest one to generate)
Array of arrays
Array inside object, same name as field
Map inside object, same name as field
Array inside object, field in response starts with the name of the autocompleter("state" in this example)
No name match, use first array found, and hope for the best
Load characters while user types (when text size >= 3)
Hide dropdown arrow
Limit options shown to 3
All matching options are shown
Set dropdown height and width, in pixels
Disable it when page is loaded
Disable it/enable it using JavaScript
Reload options when topic is published
Submit form when options are loaded
Filter fields top be submitted when options are loaded (return true to include)
Link two autocompleters, using topics
Show options, but don't make suggestion (autocomple) in the textbox
Prevent options from loading when page loads