You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Olivier DUTRIEUX <ol...@pasteur.fr> on 2017/09/30 21:21:10 UTC

PrependJavaScript to replace a composant with animation

Hello,

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(){$('#identifiedPerson17f').selectpicker('destroy');})();(function(){notify|var c=$('#identifiedPersonContainer161.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}})();

Thanks advance for your help

Duto

RE: PrependJavaScript to replace a composant with animation

Posted by Olivier DUTRIEUX <ol...@pasteur.fr>.
Hello,

I have time to check this problem :

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.


-- 
Duto


> -----Message d'origine-----
> De : Martin Grigorov [mailto:mgrigorov@apache.org]
> Envoyé : mercredi 4 octobre 2017 10:13
> À : users@wicket.apache.org
> Objet : Re: PrependJavaScript to replace a composant with animation
> 
> Hi,
> 
> Put a breakpoint inside processEvaluation() method [1] and see what goes
> wrong.
> 
> 
> 1.
> https://github.com/apache/wicket/blob/58a7106d74de02cc9f193d95613b6c1
> f3483ca7b/wicket-
> core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-
> jquery.js#L1158
> 
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov

Re: PrependJavaScript to replace a composant with animation

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Put a breakpoint inside processEvaluation() method [1] and see what goes
wrong.


1.
https://github.com/apache/wicket/blob/58a7106d74de02cc9f193d95613b6c1f3483ca7b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L1158

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Oct 3, 2017 at 4:19 PM, Olivier DUTRIEUX <
olivier.dutrieux@pasteur.fr> wrote:

> This is a special syntax of wicket : http://wicketinaction.com/
> 2013/02/replace-components-with-animation/
>
> Anybody can't help me ?
>
> --
> Olivier Dutrieux
> Groupe Projets (Tél : 31 62)
>
> > -----Message d'origine-----
> > De : Tobias Soloschenko [mailto:tobiassoloschenko@googlemail.com]
> > Envoyé : dimanche 1 octobre 2017 00:35
> > À : users@wicket.apache.org
> > Objet : Re: PrependJavaScript to replace a composant with animation
> >
> > Hi,
> >
> > are you able to try to replace this by a normal if block:
> >
> > ......format("notify|var......
> >
> > Seems that this shortcut is causing the issue.
> >
> > kind regards
> >
> > Tobias
> >
> > > Am 30.09.2017 um 23:21 schrieb Olivier DUTRIEUX
> > <ol...@pasteur.fr>:
> > >
> > > Hello,
> > >
> > > 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(){$('#identifiedPerson17f').selectpicker('destroy');})();(
> function(){n
> > otify|var
> > c=$('#identifiedPersonContainer161.collapse');if(c.length){c.on('
> hidden.bs.co
> > llapse',function(){notify();});c.collapse('hide');}else{notify();}})();
> > >
> > > Thanks advance for your help
> > >
> > > Duto
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: PrependJavaScript to replace a composant with animation

Posted by Olivier DUTRIEUX <ol...@pasteur.fr>.
This is a special syntax of wicket : http://wicketinaction.com/2013/02/replace-components-with-animation/

Anybody can't help me ?

-- 
Olivier Dutrieux
Groupe Projets (Tél : 31 62)

> -----Message d'origine-----
> De : Tobias Soloschenko [mailto:tobiassoloschenko@googlemail.com]
> Envoyé : dimanche 1 octobre 2017 00:35
> À : users@wicket.apache.org
> Objet : Re: PrependJavaScript to replace a composant with animation
> 
> Hi,
> 
> are you able to try to replace this by a normal if block:
> 
> ......format("notify|var......
> 
> Seems that this shortcut is causing the issue.
> 
> kind regards
> 
> Tobias
> 
> > Am 30.09.2017 um 23:21 schrieb Olivier DUTRIEUX
> <ol...@pasteur.fr>:
> >
> > Hello,
> >
> > 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(){$('#identifiedPerson17f').selectpicker('destroy');})();(function(){n
> otify|var
> c=$('#identifiedPersonContainer161.collapse');if(c.length){c.on('hidden.bs.co
> llapse',function(){notify();});c.collapse('hide');}else{notify();}})();
> >
> > Thanks advance for your help
> >
> > Duto
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org


Re: PrependJavaScript to replace a composant with animation

Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi,

are you able to try to replace this by a normal if block:

......format("notify|var......

Seems that this shortcut is causing the issue.

kind regards

Tobias

> Am 30.09.2017 um 23:21 schrieb Olivier DUTRIEUX <ol...@pasteur.fr>:
> 
> Hello,
> 
> 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(){$('#identifiedPerson17f').selectpicker('destroy');})();(function(){notify|var c=$('#identifiedPersonContainer161.collapse');if(c.length){c.on('hidden.bs.collapse',function(){notify();});c.collapse('hide');}else{notify();}})();
> 
> Thanks advance for your help
> 
> Duto

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: PrependJavaScript to replace a composant with animation

Posted by Martin Grigorov <mg...@apache.org>.
Hi Olivier,

On Wed, Nov 1, 2017 at 9:46 PM, Olivier DUTRIEUX <
olivier.dutrieux@pasteur.fr> wrote:

> No new about this problem : I need to create a jira issue ?
>

Yes, please!


>
> Duto
>
>
> > -----Message d'origine-----
> > De : Olivier DUTRIEUX [mailto:olivier.dutrieux@pasteur.fr]
> > Envoyé : samedi 30 septembre 2017 23:21
> > À : users@wicket.apache.org
> > Objet : PrependJavaScript to replace a composant with animation
> >
> > Hello,
> >
> > 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(){$('#identifiedPerson17f').selectpicker('destroy');})();(
> function(){n
> > otify|var
> > c=$('#identifiedPersonContainer161.collapse');if(c.length){c.on('
> hidden.bs.co
> > llapse',function(){notify();});c.collapse('hide');}else{notify();}})();
> >
> > Thanks advance for your help
> >
> > Duto
>

RE: PrependJavaScript to replace a composant with animation

Posted by Olivier DUTRIEUX <ol...@pasteur.fr>.
No new about this problem : I need to create a jira issue ?

Duto


> -----Message d'origine-----
> De : Olivier DUTRIEUX [mailto:olivier.dutrieux@pasteur.fr]
> Envoyé : samedi 30 septembre 2017 23:21
> À : users@wicket.apache.org
> Objet : PrependJavaScript to replace a composant with animation
> 
> Hello,
> 
> 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(){$('#identifiedPerson17f').selectpicker('destroy');})();(function(){n
> otify|var
> c=$('#identifiedPersonContainer161.collapse');if(c.length){c.on('hidden.bs.co
> llapse',function(){notify();});c.collapse('hide');}else{notify();}})();
> 
> Thanks advance for your help
> 
> Duto