Author: musachy Date: Thu Apr 12 19:41:20 2007 New Revision: 528326 URL: http://svn.apache.org/viewvc?view=rev&rev=528326 Log: Update Ajax Tags javadocs
Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java?view=diff&rev=528326&r1=528325&r2=528326 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java (original) +++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java Thu Apr 12 19:41:20 2007 @@ -38,8 +38,8 @@ * <!-- END SNIPPET: javadoc --> * <p>Examples</p> * - * <p>Update target content with html returned from an action:</p> * <!-- START SNIPPET: example1 --> + * <p>Update target content with html returned from an action:</p> * <pre> * <div id="div1">Div 1</div> * <s:url id="ajaxTest" value="/AjaxTest.action"/> @@ -50,8 +50,8 @@ * </pre> * <!-- END SNIPPET: example1 --> * - * <p>Submit form(anchor inside the form):</p> * <!-- START SNIPPET: example2 --> + * <p>Submit form(anchor inside the form):</p> * <pre> * <s:form id="form" action="AjaxTest"> * <input type="textbox" name="data"> @@ -60,8 +60,8 @@ * </pre> * <!-- END SNIPPET: example2 --> * - * <p>Submit form(anchor outside the form)</p> * <!-- START SNIPPET: example3 --> + * <p>Submit form(anchor outside the form)</p> * <pre> * <s:form id="form" action="AjaxTest"> * <input type="textbox" name="data"> @@ -71,8 +71,8 @@ * </pre> * <!-- END SNIPPET: example3 --> * - * <p>Using topics:</p> * <!-- START SNIPPET: example4 --> + * <p>Using topics:</p> * <pre> * <script type="text/javascript"> * dojo.event.topic.subscribe("/before", function(data, type, e){ @@ -87,7 +87,6 @@ * <sx:a beforeNotifyTopics="/before">Publish topics</sx:a> * </pre> * <!-- END SNIPPET: example4 --> - * </pre> */ @StrutsTag(name="a", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.AnchorTag", description="Renders an HTML anchor element that when clicked calls a URL via remote XMLHttpRequest and updates " + "its targets content") Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java?view=diff&rev=528326&r1=528325&r2=528326 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java (original) +++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java Thu Apr 12 19:41:20 2007 @@ -33,55 +33,90 @@ /** * <!-- START 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 --> + * is used to populate the autocompleter, the output of the action must be a well formed JSON string. </p> + * <p>The autocompleter follows this rule to find its datasource:<p> + * <p>1. If the response is an array, assume that it contains 2-dimension array elements, like: * <pre> - * <!-- START SNIPPET: examples --> - * <b>Autocompleter that gets its list from an action:</b> - * - * <sx:autocompleter name="autocompleter1" href="%{jsonList}"/> - * - * Which expects a response like: - * * [ * ["Text1", "Value1"], * ["Text2", "Value2"] * ] + * </pre> + * <p>2. If a value is specified in the "dataFieldName" attribute, and the response has a field with that + * name, assume that's the datasource, which can be an array of 2-dimension array elements, or a map, + * like (assuming dataFieldName="states"):</p> + * <pre> + * { + * "states" : [ + * ["Alabama","AL"], + * ["Alaska","AK"] + * ] + * } * - * 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): + * or * * { - * autocompleter1:[ - * ["Text1", "Value1"], - * ["Text2", "Value2"] + * "states" : { + * "Alabama" : "AL", + * "Alaska" : "AK" + * } + * } + * </pre> + * <p>4. If there is a field that starts with the value specified on the "name" attribute, assume + * that's the datasource, like (assuming name="state"):</p> + * <pre> + * { + * "states" : [ + * ["Alabama","AL"], + * ["Alaska","AK"] * ] * } + * </pre> + * <p>5. Use first array that is found, like:<p> + * <pre> + * { + * "anything" : [ + * ["Text1", "Value1"], + * ["Text2", "Value2"] + * ] + * } + * </pre> + * <!-- END SNIPPET: javadoc --> + * <p>Examples</p> + * <!-- START SNIPPET: example1 --> + * <p>Autocompleter that gets its list from an action:</p> + * <pre> + * <sx:autocompleter name="autocompleter1" href="%{jsonList}"/> + * </pre> + * <!-- END SNIPPET: example1 --> * - * 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> - * + * <!-- START SNIPPET: example2 --> + * <p>Autocompleter that uses a list:</p> + * <pre> * <s:autocompleter name="test" list="{'apple','banana','grape','pear'}" autoComplete="false"/> + * </pre> + * <!-- END SNIPPET: example2 --> * - * <b>Autocompleter that reloads its content everytime the text changes (and the length of the text is greater than 3):</b> - * + * <!-- START SNIPPET: example3 --> + * <p>Autocompleter that reloads its content everytime the text changes (and the length of the text is greater than 3):</p> + * <pre> * <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 + * </pre> + * <!-- END SNIPPET: example3 --> * - * <b>Linking two autocompleters:</b> - * + * <!-- START SNIPPET: example4 --> + * <p>Linking two autocompleters:</p> + * <pre> * <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> + * </pre> + * <!-- END SNIPPET: example4 --> */ @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 {