You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/11/26 00:46:21 UTC
svn commit: r479236 - in /struts/struts2/trunk:
apps/showcase/src/main/resources/ apps/showcase/src/main/webapp/ajax/
core/src/main/java/org/apache/struts2/components/
core/src/main/java/org/apache/struts2/views/velocity/
core/src/main/resources/META-I...
Author: husted
Date: Sat Nov 25 15:46:21 2006
New Revision: 479236
URL: http://svn.apache.org/viewvc?view=rev&rev=479236
Log:
WW-1520 Add Autocompleter AJAX tag - Apply patch submitted by Musachy Barroso
In the showcase, the ajax/autocompleter/index.jsp page doesn't seem to work correctly for me. There are four dropdown controls, but only the second (using a local list) presents a list for me. The third control (force valid options) does seem to clear whatever I put in, but I don't know what the valid values are suppose to be (become no list drops down). I seem to have the same problems with IE and FF.
Modified:
struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/index.jsp
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld
struts/struts2/trunk/core/src/main/resources/template/ajax/div-close.ftl
Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml?view=diff&rev=479236&r1=479235&r2=479236
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml (original)
+++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-ajax.xml Sat Nov 25 15:46:21 2006
@@ -28,6 +28,10 @@
<result>/ajax/testjs.jsp</result>
</action>
+ <action name="JSONList">
+ <result>/ajax/JSONList.js</result>
+ </action>
+
<action name="tree">
<result>/ajax/tree/tree.jsp</result>
</action>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/index.jsp?view=diff&rev=479236&r1=479235&r2=479236
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/index.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/index.jsp Sat Nov 25 15:46:21 2006
@@ -9,6 +9,7 @@
<ul>
<li><a href="remotediv">Remote div tag</a></li>
+ <li><a href="autocompleter">Autocompleter combobox tag</a></li>
<li><a href="remotelink">Remote link tag</a></li>
<li><a href="remotebutton">Remote button tag</a></li>
<li><a href="tabbedpanel">Tabbed panel</a></li>
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java?view=diff&rev=479236&r1=479235&r2=479236
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java Sat Nov 25 15:46:21 2006
@@ -110,9 +110,7 @@
public void evaluateExtraParams() {
super.evaluateExtraParams();
- Object value = findValue(list, "list",
- "You must specify a collection/array/map/enumeration/iterator. " +
- "Example: people or people.{name}");
+ Object value = findListValue();
if (headerKey != null) {
addParameter("headerKey", findString(headerKey));
@@ -124,44 +122,49 @@
addParameter("emptyOption", findValue(emptyOption, Boolean.class));
}
- if (value instanceof Collection) {
- Collection tmp = (Collection) value;
- addParameter("list", tmp);
- if (listKey != null) {
- addParameter("listKey", listKey);
- }
- if (listValue != null) {
- addParameter("listValue", listValue);
- }
- }
- else if (value instanceof Map) {
- Map tmp = (Map) value;
- addParameter("list", MakeIterator.convert(tmp));
- addParameter("listKey", "key");
- addParameter("listValue", "value");
- }
- else if (value.getClass().isArray()) {
- Iterator i = MakeIterator.convert(value);
- addParameter("list", i);
- if (listKey != null) {
- addParameter("listKey", listKey);
- }
- if (listValue != null) {
- addParameter("listValue", listValue);
- }
- }
- else {
- Iterator i = MakeIterator.convert(value);
- addParameter("list", i);
- if (listKey != null) {
- addParameter("listKey", listKey);
- }
- if (listValue != null) {
- addParameter("listValue", listValue);
+ if (value != null) {
+ if (value instanceof Collection) {
+ Collection tmp = (Collection) value;
+ addParameter("list", tmp);
+ if (listKey != null) {
+ addParameter("listKey", listKey);
+ }
+ if (listValue != null) {
+ addParameter("listValue", listValue);
+ }
+ } else if (value instanceof Map) {
+ Map tmp = (Map) value;
+ addParameter("list", MakeIterator.convert(tmp));
+ addParameter("listKey", "key");
+ addParameter("listValue", "value");
+ } else if (value.getClass().isArray()) {
+ Iterator i = MakeIterator.convert(value);
+ addParameter("list", i);
+ if (listKey != null) {
+ addParameter("listKey", listKey);
+ }
+ if (listValue != null) {
+ addParameter("listValue", listValue);
+ }
+ } else {
+ Iterator i = MakeIterator.convert(value);
+ addParameter("list", i);
+ if (listKey != null) {
+ addParameter("listKey", listKey);
+ }
+ if (listValue != null) {
+ addParameter("listValue", listValue);
+ }
}
}
}
+ protected Object findListValue() {
+ return findValue(list, "list",
+ "You must specify a collection/array/map/enumeration/iterator. " +
+ "Example: people or people.{name}");
+ }
+
/**
* Iteratable source to populate from. If this is missing, the select widget is simply not displayed.
* @s.tagattribute required="true"
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java?view=diff&rev=479236&r1=479235&r2=479236
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java Sat Nov 25 15:46:21 2006
@@ -47,6 +47,7 @@
import org.apache.struts2.views.velocity.components.ActionErrorDirective;
import org.apache.struts2.views.velocity.components.ActionMessageDirective;
import org.apache.struts2.views.velocity.components.AnchorDirective;
+import org.apache.struts2.views.velocity.components.AutocompleterDirective;
import org.apache.struts2.views.velocity.components.BeanDirective;
import org.apache.struts2.views.velocity.components.CheckBoxDirective;
import org.apache.struts2.views.velocity.components.CheckBoxListDirective;
@@ -571,6 +572,7 @@
addDirective(sb, DatePickerDirective.class);
addDirective(sb, DropdownDateTimePickerDirective.class);
addDirective(sb, DivDirective.class);
+ addDirective(sb, AutocompleterDirective.class);
addDirective(sb, DoubleSelectDirective.class);
addDirective(sb, FileDirective.class);
addDirective(sb, FormDirective.class);
Modified: struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld?view=diff&rev=479236&r1=479235&r2=479236
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld (original)
+++ struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld Sat Nov 25 15:46:21 2006
@@ -2813,6 +2813,373 @@
</tag>
<tag>
+ <name>autocompleter</name>
+ <tag-class>org.apache.struts2.views.jsp.ui.AutocompleterTag</tag-class>
+ <body-content>JSP</body-content>
+ <description><![CDATA[Render HTML div providing content from remote call via AJAX]]></description>
+
+ <attribute>
+ <name>autoComplete</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[sets if combobox must perform autocomplete]]></description>
+
+ </attribute>
+ <attribute>
+ <name>forceValidOption</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[sets if user can enter a value that is not in a list]]></description>
+
+ </attribute>
+ <attribute>
+ <name>listLength</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[limits list of visible rows, scroll on rest ]]></description>
+
+ </attribute>
+ <attribute>
+ <name>searchDelay</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[set delay before making the search]]></description>
+
+ </attribute>
+ <attribute>
+ <name>theme</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[The theme to use for the element. <b>This tag will usually use the ajax theme.</b>]]></description>
+
+ </attribute>
+ <attribute>
+ <name>href</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[The URL to call to obtain the content]]></description>
+
+ </attribute>
+ <attribute>
+ <name>list</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Iteratable source to populate from. If this is missing, the select widget is simply not displayed.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>maxlength</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[HTML maxlength attribute]]></description>
+
+ </attribute>
+ <attribute>
+ <name>maxLength</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Deprecated. Use maxlength instead.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>readonly</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Whether the input is readonly]]></description>
+
+ </attribute>
+ <attribute>
+ <name>size</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[HTML size attribute]]></description>
+
+ </attribute>
+ <attribute>
+ <name>openTemplate</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set template to use for opening the rendered html.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>templateDir</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[The template directory (other than default) to used to find the themes and hence the template.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>template</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[The template (other than default) to use for rendering the element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>cssClass</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[The css class to use for element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>cssStyle</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[The css style definitions for element ro use]]></description>
+
+ </attribute>
+ <attribute>
+ <name>title</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html title attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>disabled</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html disabled attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>label</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Label expression used for rendering a element specific label]]></description>
+
+ </attribute>
+ <attribute>
+ <name>labelposition</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[define label position of form element (top/left)]]></description>
+
+ </attribute>
+ <attribute>
+ <name>requiredposition</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[define required position of required form element (left|right)]]></description>
+
+ </attribute>
+ <attribute>
+ <name>name</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[The name to set for element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>key</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[The i18n key attribute to be specified in place of the name, value and label attributes]]></description>
+
+ </attribute>
+
+ <attribute>
+ <name>required</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[If set to true, the rendered element will indicate that input is required]]></description>
+
+ </attribute>
+ <attribute>
+ <name>tabindex</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html tabindex attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>value</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Preset the value of input element.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onclick</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onclick attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>ondblclick</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html ondblclick attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onmousedown</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onmousedown attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onmouseup</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onmouseup attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onmouseover</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onmouseover attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onmousemove</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onmousemove attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onmouseout</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onmouseout attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onfocus</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onfocus attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onblur</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onblur attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onkeypress</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onkeypress attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onkeydown</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onkeydown attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onkeyup</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onkeyup attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onselect</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onselect attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onchange</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html onchange attribute on rendered html element]]></description>
+
+ </attribute>
+ <attribute>
+ <name>accesskey</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the html accesskey attribute on rendered html ekement]]></description>
+
+ </attribute>
+ <attribute>
+ <name>tooltip</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the tooltip of this particular component]]></description>
+
+ </attribute>
+ <attribute>
+ <name>tooltipConfig</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Set the tooltip configuration]]></description>
+
+ </attribute>
+ <attribute>
+ <name>id</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[id for referencing element. For UI and form tags it will be used as HTML id attribute]]></description>
+
+ </attribute>
+
+ </tag>
+ <tag>
+
<name>label</name>
<tag-class>org.apache.struts2.views.jsp.ui.LabelTag</tag-class>
<body-content>JSP</body-content>
Modified: struts/struts2/trunk/core/src/main/resources/template/ajax/div-close.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/ajax/div-close.ftl?view=diff&rev=479236&r1=479235&r2=479236
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/template/ajax/div-close.ftl (original)
+++ struts/struts2/trunk/core/src/main/resources/template/ajax/div-close.ftl Sat Nov 25 15:46:21 2006
@@ -1,6 +1 @@
</div>
-<#if parameters.updateFreq?if_exists != "">
- <script language="javascript">
-
- </script>
-</#if>