diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java
index 779055b41..41315d2d4 100644
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java
+++ b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java
@@ -147,6 +147,7 @@ public class Autocompleter extends ComboBox {
protected String afterNotifyTopics;
protected String errorNotifyTopics;
protected String valueNotifyTopics;
+ protected String resultsLimit;
public Autocompleter(ValueStack stack, HttpServletRequest request,
HttpServletResponse response) {
@@ -205,13 +206,13 @@ public class Autocompleter extends ComboBox {
addParameter("showDownArrow", findValue(showDownArrow, Boolean.class));
else
addParameter("showDownArrow", Boolean.TRUE);
- if(templateCssPath != null)
+ if (templateCssPath != null)
addParameter("templateCssPath", findString(templateCssPath));
- if(iconPath != null)
+ if (iconPath != null)
addParameter("iconPath", findString(iconPath));
- if(dataFieldName != null)
- addParameter("dataFieldName", findString(dataFieldName));
- if(keyName != null)
+ if (dataFieldName != null)
+ addParameter("dataFieldName", findString(dataFieldName));
+ if (keyName != null)
addParameter("keyName", findString(keyName));
else {
keyName = name + "Key";
@@ -229,6 +230,8 @@ public class Autocompleter extends ComboBox {
addParameter("errorNotifyTopics", findString(errorNotifyTopics));
if (valueNotifyTopics != null)
addParameter("valueNotifyTopics", findString(valueNotifyTopics));
+ if (resultsLimit != null)
+ addParameter("searchLimit", findString(resultsLimit));
}
@Override
@@ -397,4 +400,9 @@ public class Autocompleter extends ComboBox {
public void setValueNotifyTopics(String valueNotifyTopics) {
this.valueNotifyTopics = valueNotifyTopics;
}
+
+ @StrutsTagAttribute(description="Limit how many results are shown as autocompletion options", defaultValue="30")
+ public void setResultsLimit(String resultsLimit) {
+ this.resultsLimit = resultsLimit;
+ }
}
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTag.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTag.java
index 144055308..f8d5aeb0a 100644
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTag.java
+++ b/plugins/dojo/src/main/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTag.java
@@ -59,6 +59,7 @@ public class AutocompleterTag extends ComboBoxTag {
protected String afterNotifyTopics;
protected String errorNotifyTopics;
protected String valueNotifyTopics;
+ protected String resultsLimit;
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new Autocompleter(stack, req, res);
@@ -92,6 +93,7 @@ public class AutocompleterTag extends ComboBoxTag {
autocompleter.setBeforeNotifyTopics(beforeNotifyTopics);
autocompleter.setErrorNotifyTopics(errorNotifyTopics);
autocompleter.setValueNotifyTopics(valueNotifyTopics);
+ autocompleter.setResultsLimit(resultsLimit);
}
public void setAutoComplete(String autoComplete) {
@@ -193,4 +195,8 @@ public class AutocompleterTag extends ComboBoxTag {
public void setValueNotifyTopics(String valueNotifyTopics) {
this.valueNotifyTopics = valueNotifyTopics;
}
+
+ public void setResultsLimit(String resultsLimit) {
+ this.resultsLimit = resultsLimit;
+ }
}
diff --git a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts/widget/ComboBox.js b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts/widget/ComboBox.js
index e18e7469a..8e1db7d6f 100644
--- a/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts/widget/ComboBox.js
+++ b/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts/widget/ComboBox.js
@@ -5,7 +5,7 @@ dojo.require("dojo.widget.ComboBox");
struts.widget.ComboBoxDataProvider = function(combobox, node){
this.data = [];
- this.searchLimit = 30;
+ this.searchLimit = combobox.searchLimit;
this.searchType = "STARTSTRING"; // may also be "STARTWORD" or "SUBSTRING"
this.caseSensitive = false;
// for caching optimizations
@@ -236,6 +236,10 @@ dojo.widget.defineWidget(
dataFieldName : "",
keyName: "",
templateCssPath: dojo.uri.dojoUri("struts/ComboBox.css"),
+
+ //how many results are shown
+ searchLimit : 30,
+
//from Dojo's ComboBox
showResultList: function() {
// Our dear friend IE doesnt take max-height so we need to calculate that on our own every time
diff --git a/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl b/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl
index 07517d6da..09f3090cc 100644
--- a/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl
+++ b/plugins/dojo/src/main/resources/template/ajax/autocompleter.ftl
@@ -104,6 +104,9 @@
<#if parameters.dataFieldName?if_exists != "">
dataFieldName="${parameters.dataFieldName?html}"
#if>
+<#if parameters.searchLimit?if_exists != "">
+ searchLimit="${parameters.searchLimit?html}"
+#if>
<#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
<#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
<#if parameters.href?exists>
diff --git a/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTest.java b/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTest.java
index f5e24e346..84cdd3ad7 100644
--- a/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTest.java
+++ b/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AutocompleterTest.java
@@ -48,6 +48,7 @@ public class AutocompleterTest extends AbstractUITagTest {
tag.setTemplateCssPath("j");
tag.setDataFieldName("k");
tag.setValueNotifyTopics("l");
+ tag.setResultsLimit("2");
tag.doStartTag();
tag.doEndTag();
@@ -70,6 +71,7 @@ public class AutocompleterTest extends AbstractUITagTest {
tag.setIconPath("i");
tag.setTemplateCssPath("j");
tag.setValueNotifyTopics("k");
+ tag.setResultsLimit("2");
tag.doStartTag();
tag.doEndTag();
diff --git a/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-1.txt b/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-1.txt
index b3d764c91..9755f13ba 100644
--- a/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-1.txt
+++ b/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-1.txt
@@ -18,4 +18,5 @@
visibleDownArrow="false"
buttonSrc="i"
templateCssPath="j"
- dataFieldName="k"/>
+ dataFieldName="k"
+ searchLimit="2"/>
diff --git a/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-2.txt b/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-2.txt
index c780b4e4c..fe2d7cd51 100644
--- a/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-2.txt
+++ b/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Autocompleter-2.txt
@@ -13,6 +13,7 @@
visibleDownArrow="true"
buttonSrc="i"
templateCssPath="j"
+ searchLimit="2"
>