Author: hermanns
Date: Thu Nov 30 14:39:50 2006
New Revision: 481097
URL: http://svn.apache.org/viewvc?view=rev&rev=481097
Log:
Autocompleter problems
The dropdown of the autocompleter shows on the wrong place when the
autocompleter.style.left.x != 0.
Make autocompleter consistent with the other ajax tags attributes:
o Add formId and formFilter to make it able to submit a form
o Add beforeLoading and afterLoading
o Add refreshListenTopic and onValueChangedPublishTopic
o Add delay
Issue Number: WW-1529
Submitted by: Musachy Barroso
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java
struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld
struts/struts2/trunk/core/src/main/resources/template/ajax/autocompleter.ftl
struts/struts2/trunk/core/src/main/resources/template/simple/autocompleter.ftl
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-1.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-2.txt
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java?view=diff&rev=481097&r1=481096&r2=481097
==============================================================================
---
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java
(original)
+++
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java
Thu Nov 30 14:39:50 2006
@@ -50,14 +50,20 @@
public static final String TEMPLATE = "autocompleter";
final private static String COMPONENT_NAME = Autocompleter.class.getName();
- private String forceValidOption;
- private String searchType;
- private String autoComplete;
- private String searchDelay;
- private String disabled;
- private String href;
- private String dropdownWidth;
- private String dropdownHeight;
+ protected String forceValidOption;
+ protected String searchType;
+ protected String autoComplete;
+ protected String delay;
+ protected String disabled;
+ protected String href;
+ protected String dropdownWidth;
+ protected String dropdownHeight;
+ protected String formId;
+ protected String formFilter;
+ protected String refreshListenTopic;
+ protected String onValueChangedPublishTopic;
+ protected String afterLoading;
+ protected String beforeLoading;
public Autocompleter(ValueStack stack, HttpServletRequest request,
HttpServletResponse response) {
@@ -82,8 +88,8 @@
addParameter("searchType", findString(searchType));
if (autoComplete != null)
addParameter("autoComplete", findValue(autoComplete,
Boolean.class));
- if (searchDelay != null)
- addParameter("searchDelay", findValue(searchDelay, Integer.class));
+ if (delay != null)
+ addParameter("delay", findValue(delay, Integer.class));
if (disabled != null)
addParameter("disabled", findValue(disabled, Boolean.class));
if (href != null) {
@@ -95,6 +101,18 @@
addParameter("dropdownHeight", findValue(dropdownHeight,
Integer.class));
if (dropdownWidth != null)
addParameter("dropdownWidth", findValue(dropdownWidth,
Integer.class));
+ if (formFilter != null)
+ addParameter("formFilter", findString(formFilter));
+ if (formId != null)
+ addParameter("formId", findString(formId));
+ if (refreshListenTopic != null)
+ addParameter("refreshListenTopic", findString(refreshListenTopic));
+ if (onValueChangedPublishTopic != null)
+ addParameter("onValueChangedPublishTopic",
findString(onValueChangedPublishTopic));
+ if (afterLoading != null)
+ addParameter("afterLoading", findString(afterLoading));
+ if (beforeLoading != null)
+ addParameter("beforeLoading", findString(beforeLoading));
}
@@ -138,8 +156,8 @@
* set delay before making the search
* @s.tagattribute required="false" type="Integer" default="100"
*/
- public void setSearchDelay(String searchDelay) {
- this.searchDelay = searchDelay;
+ public void setDelay(String searchDelay) {
+ this.delay = searchDelay;
}
@@ -165,5 +183,58 @@
*/
public void setDropdownWidth(String width) {
this.dropdownWidth = width;
+ }
+
+ /**
+ * Function name used to filter the fields of the form.
+ * This function takes as a parameter the element and returns true if the
element
+ * must be included.
+ * @s.tagattribute required="false" type="String"
+ */
+ public void setFormFilter(String formFilter) {
+ this.formFilter = formFilter;
+ }
+
+ /**
+ * Form id whose fields will be serialized and passed as parameters
+ *
+ * @s.tagattribute required="false" type="String"
+ */
+ public void setFormId(String formId) {
+ this.formId = formId;
+ }
+
+ /**
+ * Topic that will trigger a re-fetch
+ *
+ * @s.tagattribute required="false" type="String"
+ */
+ public void setRefreshListenTopic(String refreshListenTopic) {
+ this.refreshListenTopic = refreshListenTopic;
+ }
+
+ /**
+ * Topic that will be published when content is fetched.
+ * New Value is passed as parameter.
+ * @s.tagattribute required="false" type="String"
+ */
+ public void setOnValueChangedPublishTopic(String
onValueChangedPublishTopic) {
+ this.onValueChangedPublishTopic = onValueChangedPublishTopic;
+ }
+
+ /**
+ * Javascript code name that will be executed after the content has been
fetched
+ * @s.tagattribute required="false" type="String"
+ */
+ public void setAfterLoading(String afterLoading) {
+ this.afterLoading = afterLoading;
+ }
+
+ /**
+ * Javascript code that will be executed before the content has been
fetched
+ * @s.tagattribute required="false" type="String"
+ */
+ public void setBeforeLoading(String beforeLoading) {
+ this.beforeLoading = beforeLoading;
}
}
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java?view=diff&rev=481097&r1=481096&r2=481097
==============================================================================
---
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java
(original)
+++
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java
Thu Nov 30 14:39:50 2006
@@ -34,14 +34,21 @@
public class AutocompleterTag extends ComboBoxTag {
private static final long serialVersionUID = -1112470447573172581L;
- private String forceValidOption;
- private String searchType;
- private String autoComplete;
- private String searchDelay;
- private String disabled;
- private String href;
- private String dropdownWidth;
- private String dropdownHeight;
+ protected String forceValidOption;
+ protected String searchType;
+ protected String autoComplete;
+ protected String searchDelay;
+ protected String disabled;
+ protected String href;
+ protected String dropdownWidth;
+ protected String dropdownHeight;
+ protected String formId;
+ protected String formFilter;
+ protected String refreshListenTopic;
+ protected String refreshPublishTopic;
+ protected String onValueChangedPublishTopic;;
+ protected String afterLoading;
+ protected String beforeLoading;
public Component getBean(ValueStack stack, HttpServletRequest req,
HttpServletResponse res) {
return new Autocompleter(stack, req, res);
@@ -55,10 +62,16 @@
autocompleter.setDisabled(disabled);
autocompleter.setForceValidOption(forceValidOption);
autocompleter.setHref(href);
- autocompleter.setSearchDelay(searchDelay);
+ autocompleter.setDelay(searchDelay);
autocompleter.setSearchType(searchType);
autocompleter.setDropdownHeight(dropdownHeight);
autocompleter.setDropdownWidth(dropdownWidth);
+ autocompleter.setFormFilter(formFilter);
+ autocompleter.setFormId(formId);
+ autocompleter.setRefreshListenTopic(refreshListenTopic);
+
autocompleter.setOnValueChangedPublishTopic(onValueChangedPublishTopic);
+ autocompleter.setBeforeLoading(beforeLoading);
+ autocompleter.setAfterLoading(afterLoading);
}
public void setAutoComplete(String autoComplete) {
@@ -91,6 +104,34 @@
public void setDropdownWidth(String width) {
this.dropdownWidth = width;
+ }
+
+ public void setFormFilter(String formFilter) {
+ this.formFilter = formFilter;
+ }
+
+ public void setFormId(String formId) {
+ this.formId = formId;
+ }
+
+ public void setRefreshListenTopic(String refreshListenTopic) {
+ this.refreshListenTopic = refreshListenTopic;
+ }
+
+ public void setRefreshPublishTopic(String refreshPublishTopic) {
+ this.refreshPublishTopic = refreshPublishTopic;
+ }
+
+ public void setOnValueChangedPublishTopic(String
onValueChangedPublishTopic) {
+ this.onValueChangedPublishTopic = onValueChangedPublishTopic;
+ }
+
+ public void setAfterLoading(String afterLoading) {
+ this.afterLoading = afterLoading;
+ }
+
+ public void setBeforeLoading(String beforeLoading) {
+ this.beforeLoading = beforeLoading;
}
}
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=481097&r1=481096&r2=481097
==============================================================================
--- 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 Thu
Nov 30 14:39:50 2006
@@ -2827,6 +2827,58 @@
</attribute>
<attribute>
+ <name>beforeLoading</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Javascript code that will be executed before the
content has been fetched]]></description>
+
+ </attribute>
+ <attribute>
+ <name>afterLoading</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Javascript code that will be executed after the
content has been fetched]]></description>
+
+ </attribute>
+ <attribute>
+ <name>refreshListenTopic</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Topic name to listen to]]></description>
+
+ </attribute>
+ <attribute>
+ <name>onValueChangedPublishTopic</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Topic name that will be triggered when value changes.
Take the new value as parameter.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>formId</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Form id whose fields will be serialized and
passed as parameters.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>formFilter</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Function name used to filter the fields of
the form.]]></description>
+
+ </attribute>
+ <attribute>
<name>forceValidOption</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -2851,7 +2903,7 @@
</attribute>
<attribute>
- <name>searchDelay</name>
+ <name>delay</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
Modified:
struts/struts2/trunk/core/src/main/resources/template/ajax/autocompleter.ftl
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/ajax/autocompleter.ftl?view=diff&rev=481097&r1=481096&r2=481097
==============================================================================
---
struts/struts2/trunk/core/src/main/resources/template/ajax/autocompleter.ftl
(original)
+++
struts/struts2/trunk/core/src/main/resources/template/ajax/autocompleter.ftl
Thu Nov 30 14:39:50 2006
@@ -50,6 +50,24 @@
<#if parameters.tabindex?exists>
tabindex="${parameters.tabindex?html}"<#rt/>
</#if>
+<#if parameters.formId?if_exists != "">
+ formId="${parameters.formId?html}"<#rt/>
+</#if>
+<#if parameters.formFilter?if_exists != "">
+ formFilter="${parameters.formFilter?html}"<#rt/>
+</#if>
+<#if parameters.refreshListenTopic?if_exists != "">
+ refreshListenTopic="${parameters.refreshListenTopic?html}"<#rt/>
+</#if>
+<#if parameters.onValueChangedPublishTopic?if_exists != "">
+
onValueChangedPublishTopic="${parameters.onValueChangedPublishTopic?html}"<#rt/>
+</#if>
+<#if parameters.beforeLoading?if_exists != "">
+ beforeLoading="${parameters.beforeLoading?html}"<#rt/>
+</#if>
+<#if parameters.afterLoading?if_exists != "">
+ afterLoading="${parameters.afterLoading?html}"<#rt/>
+</#if>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
>
Modified:
struts/struts2/trunk/core/src/main/resources/template/simple/autocompleter.ftl
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/simple/autocompleter.ftl?view=diff&rev=481097&r1=481096&r2=481097
==============================================================================
---
struts/struts2/trunk/core/src/main/resources/template/simple/autocompleter.ftl
(original)
+++
struts/struts2/trunk/core/src/main/resources/template/simple/autocompleter.ftl
Thu Nov 30 14:39:50 2006
@@ -38,15 +38,21 @@
<#if parameters.maxlength?exists>
maxlength="${parameters.maxlength?string?html}"<#rt/>
</#if>
-<#if parameters.nameValue?exists>
- value="<@s.property value="parameters.nameValue"/>"<#rt/>
-</#if>
<#if parameters.readonly?default(false)>
readonly="readonly"<#rt/>
</#if>
<#if parameters.tabindex?exists>
tabindex="${parameters.tabindex?html}"<#rt/>
</#if>
+<#if parameters.onValueChangedPublishTopic?if_exists != "">
+
onValueChangedPublishTopic="${parameters.onValueChangedPublishTopic?html}"<#rt/>
+</#if>
+<#if parameters.beforeLoading?if_exists != "">
+ beforeLoading="${parameters.beforeLoading?html}"<#rt/>
+</#if>
+<#if parameters.afterLoading?if_exists != "">
+ afterLoading="${parameters.afterLoading?html}"<#rt/>
+</#if>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
>
<#if parameters.list?exists>
@@ -68,7 +74,7 @@
<#assign tmpListValue = stack.findString('top') />
</#if>
<option value="${tmpListKey?html}"<#rt/>
- <#if (parameters.nameValue == tmpListKey)>
+ <#if (parameters.nameValue?exists && parameters.nameValue ==
tmpListKey)>
selected="selected"<#rt/>
</#if>
><#t/>
Modified:
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java?view=diff&rev=481097&r1=481096&r2=481097
==============================================================================
---
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java
(original)
+++
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java
Thu Nov 30 14:39:50 2006
@@ -3,7 +3,7 @@
import org.apache.struts2.views.jsp.AbstractUITagTest;
/**
- * @see Autocompleter
+ * @see org.apache.struts2.components.Autocompleter
*/
public class AutocompleterTest extends AbstractUITagTest {
@@ -22,6 +22,10 @@
tag.setDisabled("c");
tag.setName("f");
tag.setValue("g");
+ tag.setBeforeLoading("h");
+ tag.setAfterLoading("i");
+ tag.setRefreshListenTopic("j");
+ tag.setOnValueChangedPublishTopic("k");
tag.doStartTag();
tag.doEndTag();
Modified:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-1.txt
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-1.txt?view=diff&rev=481097&r1=481096&r2=481097
==============================================================================
---
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-1.txt
(original)
+++
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-1.txt
Thu Nov 30 14:39:50 2006
@@ -1,12 +1,16 @@
<input
- dojoType="struts:ComboBox"
- id="f"
- dataUrl="a"
- forceValidOption="false"
- searchType="b"
- autoComplete="true"
- searchDelay="100"
- dropdownWidth="10"
- dropdownHeight="10"
- name="f"
- value="g">
+ dojoType="struts:ComboBox"
+ id="f"
+ dataUrl="a"
+ forceValidOption="false"
+ searchType="b"
+ autoComplete="true"
+ dropdownWidth="10"
+ dropdownHeight="10"
+ name="f"
+ value="g"
+ refreshListenTopic="j"
+ onValueChangedPublishTopic="k"
+ beforeLoading="h"
+ afterLoading="i"
+>
\ No newline at end of file
Modified:
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-2.txt
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-2.txt?view=diff&rev=481097&r1=481096&r2=481097
==============================================================================
---
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-2.txt
(original)
+++
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-2.txt
Thu Nov 30 14:39:50 2006
@@ -5,10 +5,9 @@
forceValidOption="false"
searchType="b"
autoComplete="true"
- searchDelay="100"
dropdownWidth="10"
dropdownHeight="10"
- name="f"value="">
- <optionvalue="d">d</option>
- <optionvalue="e">e</option>
+ name="f">
+ <option value="d">d</option>
+ <option value="e">e</option>
</select>