You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gm...@apache.org on 2007/02/23 17:04:29 UTC
svn commit: r510999 - in /myfaces/tomahawk/trunk:
core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/widget/
sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/
Author: gmuellan
Date: Fri Feb 23 08:04:28 2007
New Revision: 510999
URL: http://svn.apache.org/viewvc?view=rev&rev=510999
Log:
Applied patch for issue https://issues.apache.org/jira/browse/TOMAHAWK-258, Thx to Stefan Schuster
Added:
myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/widget/InputSuggestAjax.js
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/widget/InputSuggestAjax.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/widget/InputSuggestAjax.js?view=auto&rev=510999
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/widget/InputSuggestAjax.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojoextensions/resource/widget/InputSuggestAjax.js Fri Feb 23 08:04:28 2007
@@ -0,0 +1,41 @@
+dojo.provide("extensions.widget.InputSuggestAjax");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.ComboBox");
+dojo.require("dojo.lang.common");
+
+dojo.widget.defineWidget(
+ "extensions.widget.InputSuggestAjax",
+ dojo.widget.ComboBox,
+ {
+ templatePath: dojo.uri.dojoUri("../dojoextensions.ResourceLoader/templates/TableSuggest.html"),
+ textInputId: "",
+
+ fillInTemplate: function(args, frag) {
+ //Insert the textInputNode
+ this.textInputNode = dojo.byId(this.textInputId);
+ this.textInputNode.className = "dojoComboBox";
+ this.textInputNode.parentNode.removeChild(this.textInputNode);
+ this.domNode.insertBefore(this.textInputNode, this.downArrowNode);
+
+ //Super...
+ dojo.widget.ComboBox.prototype.fillInTemplate.call(this, args, frag);
+
+ //Connect Events
+ var that = this;
+ dojo.event.browser.addListener(this.textInputNode, "key", function(evt){ that["_handleKeyEvents"](dojo.event.browser.fixEvent(evt, this)) }, false, true);
+ dojo.event.browser.addListener(this.textInputNode, "keyUp", function(evt){ that["onKeyUp"](dojo.event.browser.fixEvent(evt, this)) }, false, true);
+ dojo.event.browser.addListener(this.textInputNode, "compositionEnd", function(evt){ that["compositionEnd"](dojo.event.browser.fixEvent(evt, this)) }, false, true);
+ dojo.event.browser.addListener(this.textInputNode, "onResize", function(evt){ that["onResize"](dojo.event.browser.fixEvent(evt, this)) }, false, true);
+
+ if (this.textInputNode.disabled == true) {
+ this.disable();
+ }
+ },
+
+ setAllValues: function(a, b) {
+ //Super...
+ dojo.widget.ComboBox.prototype.setAllValues.call(this, a, b);
+ this.textInputNode.onchange();
+ }
+ }
+);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java?view=diff&rev=510999&r1=510998&r2=510999
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java Fri Feb 23 08:04:28 2007
@@ -61,7 +61,7 @@
DojoUtils.addMainInclude(context, component, javascriptLocation, new DojoConfig());
DojoUtils.addRequire(context, component, "extensions.FacesIO");
- DojoUtils.addRequire(context, component, "dojo.widget.ComboBox");
+ DojoUtils.addRequire(context, component, "extensions.widget.InputSuggestAjax");
DojoUtils.addRequire(context, component, "dojo.event.*");
}
@@ -115,8 +115,9 @@
}
}
+ String placeHolderId = context.getViewRoot().createUniqueId();
out.startElement(HTML.DIV_ELEM, component);
- out.writeAttribute(HTML.ID_ATTR, clientId , null);
+ out.writeAttribute(HTML.ID_ATTR, placeHolderId , null);
if(inputSuggestAjax.getStyle() != null)
{
out.writeAttribute(HTML.STYLE_ATTR, inputSuggestAjax.getStyle(), null);
@@ -126,13 +127,15 @@
out.writeAttribute(HTML.CLASS_ATTR, inputSuggestAjax.getStyleClass(), null);
}
out.endElement(HTML.DIV_ELEM);
+ super.encodeEnd(context, inputSuggestAjax);
- String inputSuggestComponentVar = DojoUtils.calculateWidgetVarName(clientId);
+ String inputSuggestComponentVar = DojoUtils.calculateWidgetVarName(placeHolderId);
Map attributes = new HashedMap();
attributes.put("dataUrl", ajaxUrl);
attributes.put("mode", "remote");
+ attributes.put("textInputId", clientId);
String autoComplete = inputSuggestAjax.getAutoComplete().booleanValue()?"true":"false";
attributes.put("autoComplete", autoComplete);
@@ -146,7 +149,7 @@
mainComponentRenderedValue = escapeQuotes(mainComponentRenderedValue);
}
- DojoUtils.renderWidgetInitializationCode(context, component, "ComboBox", attributes);
+ DojoUtils.renderWidgetInitializationCode(context.getResponseWriter(), component, "extensions:InputSuggestAjax", attributes, placeHolderId.toString(), true);
out.startElement(HTML.SCRIPT_ELEM, null);
out.writeAttribute(HTML.TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
@@ -154,8 +157,6 @@
StringBuffer buffer = new StringBuffer();
buffer.append("dojo.addOnLoad(function() {\n")
- .append(inputSuggestComponentVar).append(".textInputNode.name=\"").append(idToRender).append("\";\n")
- .append(inputSuggestComponentVar).append(".textInputNode.value = \"").append(mainComponentRenderedValue).append("\";\n")
.append(inputSuggestComponentVar).append(".comboBoxValue.value = \"").append(mainComponentRenderedValue).append("\";\n")
.append(inputSuggestComponentVar).append(".onResize();\n")
.append("});\n");