Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2005

pb to access to this on event onchange on the AutoCompleteTextField

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4-RC1
    • 1.4-RC3
    • wicket-extensions
    • None
    • Windows XP, Firefox 3.0, IE7, safari 3.0

    Description

      I would like create a component that extends AjaxEditableLabel with replace TextField with AjaxEditableAutoComplete.
      And I discovert a problem in the wicket-autocomplete.js when the event onchange is rewriting (line 83) :

      83// WICKET-1280
      84 objonchangeoriginal=obj.onchange;
      85 obj.onchange=function(event)

      { 86 if(mouseactive==1)return false; 87 if(typeof objonchangeoriginal=="function")objonchangeoriginal(); 88 }

      89 objonchange=obj.onchange;

      the problem is that the objonchangeoriginal function can't access to the this object, and it's necessary because I change the onchange event on AjaxEditableAutoComplete in case I extends AjaxEditableLabel with this :

      editor.add(new EditorAjaxBehavior() {
      private static final long serialVersionUID = 1L;
      @Override
      protected void onComponentTag(ComponentTag tag) {
      super.onComponentTag(tag);
      final String saveCall = "

      {wicketAjaxGet('" + getCallbackUrl() + "&save=true&'+this.name+'='+wicketEncode(this.value)); return true;}

      ";
      tag.put("onchange", saveCall);
      }
      });

      then the best way to solve the problem is to change the invocation of objonchangeoriginal function with that :

      83// WICKET-1280
      84 objonchangeoriginal=obj.onchange;
      85 obj.onchange=function(event)

      { 86 if(mouseactive==1)return false; 87 if(typeof objonchangeoriginal=="function")objonchangeoriginal.apply(this, [event]); 88 }

      89 objonchange=obj.onchange;

      all invocation of function need to be change this with new invocation on the wicket-autocomplete.js file

      You find on attach file a simple example that's show the problem. And my version of wicket-autocomplete.js that solve the problem.

      Duto

      Attachments

        1. src.zip
          4 kB
          Olivier Dutrieux
        2. wicket-autocomplete.js
          17 kB
          Olivier Dutrieux
        3. screenshot-1.jpg
          17 kB
          Olivier Dutrieux

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            ivaynberg Igor Vaynberg
            olivier.dutrieux@pasteur.fr Olivier Dutrieux
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment