You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2008/12/11 10:29:56 UTC
svn commit: r725634 - in
/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete:
AbstractAutoCompleteBehavior.java AutoCompleteSettings.java
wicket-autocomplete.js
Author: jcompagner
Date: Thu Dec 11 01:29:55 2008
New Revision: 725634
URL: http://svn.apache.org/viewvc?rev=725634&view=rev
Log:
show complete list when the auto complete gets the focus (to be more like a combobox when you dont filter)
Modified:
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java
wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java?rev=725634&r1=725633&r2=725634&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AbstractAutoCompleteBehavior.java Thu Dec 11 01:29:55 2008
@@ -86,6 +86,8 @@
sb.append(",adjustInputWidth: ").append(settings.isAdjustInputWidth());
sb.append(",showListOnEmptyInput: ").append(settings.getShowListOnEmptyInput());
sb.append(",showListOnFocusGain: ").append(settings.getShowListOnFocusGain());
+ sb.append(",showCompleteListOnFocusGain: ").append(
+ settings.getShowCompleteListOnFocusGain());
if (settings.getCssClassName() != null)
sb.append(",className: '").append(settings.getCssClassName()).append('\'');
sb.append('}');
Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java?rev=725634&r1=725633&r2=725634&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/AutoCompleteSettings.java Thu Dec 11 01:29:55 2008
@@ -22,7 +22,8 @@
* This class encapsulates various settings for {@link AbstractAutoCompleteBehavior}. See the
* documentation for the property accessors of this class for further information.
* <p>
- * Default settings: <table>
+ * Default settings:
+ * <table>
* <tr>
* <th>setting</th>
* <th>default value</th>
@@ -54,13 +55,15 @@
private boolean showListOnEmptyInput = false;
- private String cssClassName = null;
+ private String cssClassName = null;
- private boolean adjustInputWidth = true;
-
- private boolean showListOnFocusGain = false;
+ private boolean adjustInputWidth = true;
- /**
+ private boolean showListOnFocusGain = false;
+
+ private boolean showCompleteListOnFocusGain = false;
+
+ /**
* Indicates whether the first item in the list is automatically selected when the autocomplete
* list is shown.
*
@@ -143,72 +146,98 @@
return this;
}
- /**
- * Get CSS class name to add to the autocompleter markup container
- *
- * @return CSS class name, or <code>null</code> if not used
- */
- public String getCssClassName()
- {
- return cssClassName;
- }
-
- /**
- * Sets an CSS class name to add to the autocompleter markup container
- * <p/>
- * This makes it easier to have multiple autocompleters in your application
- * with different style and layout.
- *
- * @param cssClassName valid CSS class name
- */
- public void setCssClassName(final String cssClassName)
- {
- this.cssClassName = cssClassName;
- }
-
- /**
- * Tells if wicket should adjust the width of the autocompleter selection window
- * to the width of the related input field.
- *
- * @return <code>true</code> if the autocompleter should have the same size as
- * the input field, <code>false</code> for default browser behavior
- */
- public boolean isAdjustInputWidth()
- {
- return adjustInputWidth;
- }
-
- /**
- * Adjust the width of the autocompleter selection window to the width of the related input field.
- * <p/>
- * Otherwise the size will depend on the default browser behavior and CSS.
- *
- * @param adjustInputWidth <code>true</code> if the autocompleter should have the same size as
- * the input field, <code>false</code> for default browser behavior
- */
- public void setAdjustInputWidth(final boolean adjustInputWidth)
- {
- this.adjustInputWidth = adjustInputWidth;
- }
-
- /**
+ /**
+ * Get CSS class name to add to the autocompleter markup container
+ *
+ * @return CSS class name, or <code>null</code> if not used
+ */
+ public String getCssClassName()
+ {
+ return cssClassName;
+ }
+
+ /**
+ * Sets an CSS class name to add to the autocompleter markup container
+ * <p/>
+ * This makes it easier to have multiple autocompleters in your application with different style
+ * and layout.
+ *
+ * @param cssClassName
+ * valid CSS class name
+ */
+ public void setCssClassName(final String cssClassName)
+ {
+ this.cssClassName = cssClassName;
+ }
+
+ /**
+ * Tells if wicket should adjust the width of the autocompleter selection window to the width of
+ * the related input field.
+ *
+ * @return <code>true</code> if the autocompleter should have the same size as the input field,
+ * <code>false</code> for default browser behavior
+ */
+ public boolean isAdjustInputWidth()
+ {
+ return adjustInputWidth;
+ }
+
+ /**
+ * Adjust the width of the autocompleter selection window to the width of the related input
+ * field.
+ * <p/>
+ * Otherwise the size will depend on the default browser behavior and CSS.
+ *
+ * @param adjustInputWidth
+ * <code>true</code> if the autocompleter should have the same size as the input
+ * field, <code>false</code> for default browser behavior
+ */
+ public void setAdjustInputWidth(final boolean adjustInputWidth)
+ {
+ this.adjustInputWidth = adjustInputWidth;
+ }
+
+ /**
* Indicates whether the autocomplete list will be shown when the input field receives focus.
*
- * @return true if the autocomplete list will be shown when the input field receives focus, false
- * otherwise
+ * @return true if the autocomplete list will be shown when the input field receives focus,
+ * false otherwise
+ */
+ public boolean getShowListOnFocusGain()
+ {
+ return showListOnFocusGain;
+ }
+
+ /**
+ * Sets whether the list should be shown when the input field receives focus.
+ *
+ * @param showListOnEmptyInput
+ * the flag
+ */
+ public void setShowCompleteListOnFocusGain(final boolean showCompleteListOnFocusGain)
+ {
+ this.showCompleteListOnFocusGain = showCompleteListOnFocusGain;
+ }
+
+ /**
+ * Indicates whether the autocomplete list will be shown when the input field receives focus.
+ *
+ * @return true if the autocomplete list will be shown when the input field receives focus,
+ * false otherwise
*/
- public boolean getShowListOnFocusGain()
- {
- return this.showListOnFocusGain;
- }
-
- /**
+ public boolean getShowCompleteListOnFocusGain()
+ {
+ return showCompleteListOnFocusGain;
+ }
+
+ /**
* Sets whether the list should be shown when the input field receives focus.
*
- * @param showListOnEmptyInput the flag
+ * @param showListOnEmptyInput
+ * the flag
*/
- public void setShowListOnFocusGain(final boolean showListOnFocusGain)
- {
- this.showListOnFocusGain = showListOnFocusGain;
- }
+ public void setShowListOnFocusGain(final boolean showListOnFocusGain)
+ {
+ this.showListOnFocusGain = showListOnFocusGain;
+ }
}
Modified: wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js?rev=725634&r1=725633&r2=725634&view=diff
==============================================================================
--- wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js (original)
+++ wicket/branches/wicket-1.3.x/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js Thu Dec 11 01:29:55 2008
@@ -78,6 +78,7 @@
objonblur=obj.onblur;
objonkeyup=obj.onkeyup;
objonkeypress=obj.onkeypress;
+ objonfocus=obj.onfocus;
// WICKET-1280
objonchangeoriginal=obj.onchange;
@@ -96,6 +97,17 @@
if(typeof objonblur=="function")objonblur();
}
+ obj.onfocus=function(event){
+ if (cfg.showListOnFocusGain) {
+ if (cfg.showCompleteListOnFocusGain) {
+ updateChoices(true);
+ } else {
+ updateChoices();
+ }
+ }
+ if(typeof objonfocus=="function")objonfocus();
+ }
+
obj.onkeydown=function(event){
switch(wicketKeyCode(Wicket.fixEvent(event))){
case KEY_UP:
@@ -148,10 +160,8 @@
switch(wicketKeyCode(Wicket.fixEvent(event))){
case KEY_ENTER:
return killEvent(event);
- case KEY_TAB:
- if (cfg.showListOnFocusGain)
- updateChoices();
- break;
+ case KEY_TAB:
+ break;
case KEY_UP:
case KEY_DOWN:
case KEY_ESC:
@@ -244,14 +254,25 @@
return false;
}
- function updateChoices(){
+ function updateChoices(showAll){
if(cfg.preselect==true){
selected = 0;
}
else{
selected=-1;
}
- localThrottler.throttle(getMenuId(), throttleDelay, actualUpdateChoices);
+ if (showAll) {
+ localThrottler.throttle(getMenuId(), throttleDelay, actualUpdateChoicesShowAll);
+ } else {
+ localThrottler.throttle(getMenuId(), throttleDelay, actualUpdateChoices);
+ }
+ }
+
+ function actualUpdateChoicesShowAll()
+ {
+ showIndicator();
+ var request = new Wicket.Ajax.Request(callbackUrl+"&q=", doUpdateChoices, false, true, false, "wicket-autocomplete|d");
+ request.get();
}
function actualUpdateChoices()