mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
WW-1886 Add "resultLimit" attribute to autocompleter tag
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@529633 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
+2
-1
@@ -18,4 +18,5 @@
|
||||
visibleDownArrow="false"
|
||||
buttonSrc="i"
|
||||
templateCssPath="j"
|
||||
dataFieldName="k"/>
|
||||
dataFieldName="k"
|
||||
searchLimit="2"/>
|
||||
|
||||
+1
@@ -13,6 +13,7 @@
|
||||
visibleDownArrow="true"
|
||||
buttonSrc="i"
|
||||
templateCssPath="j"
|
||||
searchLimit="2"
|
||||
>
|
||||
<option value="d">d</option>
|
||||
<option value="e">e</option>
|
||||
|
||||
Reference in New Issue
Block a user