JavaScript null reference in IE7 for autocomplete text fields added by AJAX
---------------------------------------------------------------------------
Key: WICKET-2253
URL: https://issues.apache.org/jira/browse/WICKET-2253
Project: Wicket
Issue Type: Bug
Reporter: Per Cederberg
Fix For: 1.4-RC2, 1.3.6
IE7 displays an null reference error when adding a Wicket AutoCompleteTextField
to a form as part of an AJAX response. This is caused by the INPUT DOM element
not being immediately accessible, since it is added as HTML text (via
innerHTML) instead of via the normal DOM API:s. So, the JavaScript autocomplete
initialization code must be delayed until the HTML code has been parsed and
properly inserted into the DOM tree.
We've solved this by patching our local copy of Wicket 1.3.x in the
wicket-autocomplete.js file:
@@ -39,6 +37,7 @@
var KEY_CTRL=17;
var KEY_ALT=18;
+ var initCounter=10; // counter to avoid eternal init calls
var selected=-1; // index of the currently selected item
var elementCount=0; // number of items on the auto complete list
var visible=0; // is the list visible
@@ -63,6 +62,24 @@
var throttleDelay = 300;
function initialize(){
+ // Ugly hack to avoid null reference in IE7...
+ if (initCounter <= 0) {
+ return;
+ }
+ initCounter--;
+ var obj=wicketGet(elementId);
+ if (obj == null) {
+ setTimeout(initialize, 100);
+ return;
+ }
+ initCounter=0;
+
+ // Avoid initializing same element twice
+ if (obj.wicketInit) {
+ return;
+ }
+ obj.wicketInit=true;
This is not an optimal solution, but with the current Wicket solution of
injecting HTML code as text into the DOM tree one is forced to poll for the
inserted DOM node...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.