mirror of
https://github.com/apache/struts.git
synced 2026-09-11 00:29:40 +00:00
WW-1607 Improve autocompleter's javadoc
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@522038 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -32,19 +32,56 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
* <p>The autocomplete tag is a combobox that can autocomplete text entered on the input box.
|
||||
* When used on the "simple" theme, the autocompleter can be used like the ComboBox.
|
||||
* When used on the "ajax" theme, the list can be retieved from an action. </p>
|
||||
*<!-- END SNIPPET: javadoc -->
|
||||
* <p>The autocomplete tag is a combobox that can autocomplete text entered on the input box. If an action
|
||||
* is used to populate the autocompleter, the output of the action must be a well formed JSON string. The
|
||||
* autocompleter expects and array of arrays of length 2, where the first element is the text displayed and
|
||||
* the second is the value.</p>
|
||||
* <!-- END SNIPPET: javadoc -->
|
||||
* <pre>
|
||||
* <!-- START SNIPPET: examples -->
|
||||
* <b>Autocompleter that gets its list from an action:</b>
|
||||
*
|
||||
*<!-- START SNIPPET: example -->
|
||||
*<p>Autocompleter that gets its list from an action:</p>
|
||||
*<s:autocompleter name="test" href="%{jsonList}" autoComplete="false"/>
|
||||
*<br/>
|
||||
**<p>Autocompleter that uses a list:</p>
|
||||
*<s:autocompleter name="test" list="{'apple','banana','grape','pear'}" autoComplete="false"/>
|
||||
*<br/>
|
||||
*<!-- END SNIPPET: example -->
|
||||
* <sx:autocompleter name="autocompleter1" href="%{jsonList}"/>
|
||||
*
|
||||
* Which expects a response like:
|
||||
*
|
||||
* [
|
||||
* ["Text1", "Value1"],
|
||||
* ["Text2", "Value2"]
|
||||
* ]
|
||||
*
|
||||
* Or (note that now the response is a JSON object, instead of an array, and a field inside the object matches the autocompleter's name):
|
||||
*
|
||||
* {
|
||||
* autocompleter1:[
|
||||
* ["Text1", "Value1"],
|
||||
* ["Text2", "Value2"]
|
||||
* ]
|
||||
* }
|
||||
*
|
||||
* The name of the field that contains the data for the autocompleter can be specified using the "dataFieldName" attribute.
|
||||
*
|
||||
* <b>Autocompleter that uses a list:</b>
|
||||
*
|
||||
* <s:autocompleter name="test" list="{'apple','banana','grape','pear'}" autoComplete="false"/>
|
||||
*
|
||||
* <b>Autocompleter that reloads its content everytime the text changes (and the length of the text is greater than 3):</b>
|
||||
*
|
||||
* <sx:autocompleter name="mvc" href="%{jsonList}" loadOnTextChange="true" loadMinimumCount="3"/>
|
||||
*
|
||||
* The text entered on the autocompleter is passed as a parameter to the url specified in "href", like (text is "struts"):
|
||||
*
|
||||
* http://host/example/myaction.do?mvc=struts
|
||||
*
|
||||
* <b>Linking two autocompleters:</b>
|
||||
*
|
||||
* <form id="selectForm">
|
||||
* <sx:autocompleter name="select" list="{'fruits','colors'}" valueNotifyTopics="/changed" />
|
||||
* </form>
|
||||
* <sx:autocompleter href="%{jsonList}" formId="selectForm" listenTopics="/changed"/>
|
||||
*
|
||||
* <!-- END SNIPPET: examples -->
|
||||
* <pre>
|
||||
*/
|
||||
@StrutsTag(name="autocompleter", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.AutocompleterTag", description="Renders a combobox with autocomplete and AJAX capabilities")
|
||||
public class Autocompleter extends ComboBox {
|
||||
|
||||
Reference in New Issue
Block a user