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

Exception when "identifier|code" javascript is not start on PrependJavaScript

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

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 7.9.0
    • 7.10.0, 8.0.0-M9
    • wicket
    • None
    • Windows 7 x64

    Description

      I use the functionnality of prependJavaScript to replace a composant with animation, but I have I a problem when I have two functions (on difference composants), one with normal syntax like this :

      target.prependJavaScript("$('" + c.getMarkupId() + "').selectpicker('destroy')");
      

      and I other one with special syntax for animation :

      target.prependJavaScript(String.format("notify|var c=$('#%s.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}", c.getMarkupId()));
      

      I get a error when wicket evaluate the javascript :

      ERROR: Wicket.Ajax.Call.processEvaluation: Exception evaluating javascript: SyntaxError: expected expression, got keyword 'var', text: (function(){$('#var1').selectpicker('destroy');})();(function(){notify|var c=$('#var2.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}})();
      

      The problem is that the regexp "scriptWithIdentifierR" tests that the javascript is in form of start with "identifier|code" or my javascript don't start with "identifier|code" because is :

      (function(){$('#var1').selectpicker('destroy');})();(function(){notify|var c=$('#var2.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}})();
      

      There is 2 functions : the first is a normal function but the second is "identifier|code" function.

      If I change the var "scriptWithIdentifierR" (https://tinyurl.com/y8r24b5m) to :

      new RegExp("\\(function\\(\\)\\{([a-zA-Z_]\\w*)\\|((.|\\n)*)?\\}\\)\\(\\);$");
      

      without the ^ of the first caractere that work nicely.

      Attachments

        Activity

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

          People

            mgrigorov Martin Tzvetanov Grigorov
            dutrieux Duto
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment