You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Sebastien <se...@gmail.com> on 2013/02/16 12:39:58 UTC
Wicket Ajax: Inline script header contribution issue
Dear Wicket's dev team,
A user of wicket-jquery-ui, reported me an issue which is related to an
ajax inline javascript header contribution (when src attribute is not set)
https://github.com/sebfz1/wicket-jquery-ui/issues/20
In wicket-ajax-jquery.js, #processScript assume that an inline script
should be added using Wicket.Head.addJavascript (in opposition to
Wicket.Head.addElement
for outline script)
The problem is that #addJavascript modifies the script content in any
case (content
= 'try{'+content+'}catch(e){Wicket.Log.error(e);}';), but a script element
does not necessary contains content that is designed to be executed, that
the case of a jQuery Template for instance where the tag signature look
like <script id="jquery-template-116997860" type="text/x-jquery-tmpl">
I think that #processScript should ensure that the mime type is
'text/javascript' before calling #addJavascript. If the mime type is
different, #addElement should be called rather than #addJavascript
Another option - if you want to prevent potential issues for user not
specifying the script's mime type - could be to bypass scripts (means not
calling #addJavascript but #addElement) having their mime type starting
with "text/x-", which is a convention for custom script type.
Would you like me to open a jira ?
Thanks in advance,
Sebastien.
Re: Wicket Ajax: Inline script header contribution issue
Posted by Sebastien <se...@gmail.com>.
Hi Martin,
Thanks, this is done: https://issues.apache.org/jira/browse/WICKET-5047
Best regards,
Sebastien.
On Mon, Feb 18, 2013 at 9:07 AM, Martin Grigorov <mg...@apache.org>wrote:
> Hi Sebastien,
>
> Please file a ticket.
>
Re: Wicket Ajax: Inline script header contribution issue
Posted by Martin Grigorov <mg...@apache.org>.
Hi Sebastien,
Please file a ticket.
On Sun, Feb 17, 2013 at 3:45 PM, Sebastien <se...@gmail.com> wrote:
> Hi Ernesto,
>
> Technically speaking, it is possible to achieve the same using a div, or
> even in a body script, but I do not like this idea too much. Using a header
> contribution (with an head script) is the proper way to add a jQuery
> template to the DOM...
>
> But the main question is: should Wicket assume that a script header
> contribution has a javascript content in any case?
> As I said earlier, a script tag does not necessarily contains javascript.
> It is the default scripting language for HTML5 (meaning type can be striped
> from declaration) but there is a number of different possible values.
>
> As for "official" values we can find:
> text/javascript
> text/ecmascript
> text/vbscript
> text/tcl
>
> And for the known custom script mine type, at least:
> text/x-handlebars
> text/x-jquery-tmpl
> text/x-kendo-template
> text/x-underscore-template
>
> That's the reason why I opened this thread because I think it is a
> limitation that should be handled...
>
> Thanks & best regards,
> Sebastien.
>
> On Sat, Feb 16, 2013 at 1:16 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
> > Hi Sebastien,
> >
> > Wouldn't it be possible to achieve the same with a hidden div?
> >
> > On Sat, Feb 16, 2013 at 12:39 PM, Sebastien <se...@gmail.com> wrote:
> >
> > > Dear Wicket's dev team,
> > >
> > > A user of wicket-jquery-ui, reported me an issue which is related to an
> > > ajax inline javascript header contribution (when src attribute is not
> > set)
> > > https://github.com/sebfz1/wicket-jquery-ui/issues/20
> > >
> > > In wicket-ajax-jquery.js, #processScript assume that an inline script
> > > should be added using Wicket.Head.addJavascript (in opposition to
> > > Wicket.Head.addElement
> > > for outline script)
> > > The problem is that #addJavascript modifies the script content in any
> > > case (content
> > > = 'try{'+content+'}catch(e){Wicket.Log.error(e);}';), but a script
> > element
> > > does not necessary contains content that is designed to be executed,
> that
> > > the case of a jQuery Template for instance where the tag signature look
> > > like <script id="jquery-template-116997860" type="text/x-jquery-tmpl">
> > >
> > > I think that #processScript should ensure that the mime type is
> > > 'text/javascript' before calling #addJavascript. If the mime type is
> > > different, #addElement should be called rather than #addJavascript
> > > Another option - if you want to prevent potential issues for user not
> > > specifying the script's mime type - could be to bypass scripts (means
> not
> > > calling #addJavascript but #addElement) having their mime type starting
> > > with "text/x-", which is a convention for custom script type.
> > >
> > > Would you like me to open a jira ?
> > >
> > > Thanks in advance,
> > > Sebastien.
> > >
> >
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
> > Antilia Soft
> > http://antiliasoft.com/ <http://antiliasoft.com/antilia>
> >
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>
Re: Wicket Ajax: Inline script header contribution issue
Posted by Sebastien <se...@gmail.com>.
Hi Ernesto,
Technically speaking, it is possible to achieve the same using a div, or
even in a body script, but I do not like this idea too much. Using a header
contribution (with an head script) is the proper way to add a jQuery
template to the DOM...
But the main question is: should Wicket assume that a script header
contribution has a javascript content in any case?
As I said earlier, a script tag does not necessarily contains javascript.
It is the default scripting language for HTML5 (meaning type can be striped
from declaration) but there is a number of different possible values.
As for "official" values we can find:
text/javascript
text/ecmascript
text/vbscript
text/tcl
And for the known custom script mine type, at least:
text/x-handlebars
text/x-jquery-tmpl
text/x-kendo-template
text/x-underscore-template
That's the reason why I opened this thread because I think it is a
limitation that should be handled...
Thanks & best regards,
Sebastien.
On Sat, Feb 16, 2013 at 1:16 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:
> Hi Sebastien,
>
> Wouldn't it be possible to achieve the same with a hidden div?
>
> On Sat, Feb 16, 2013 at 12:39 PM, Sebastien <se...@gmail.com> wrote:
>
> > Dear Wicket's dev team,
> >
> > A user of wicket-jquery-ui, reported me an issue which is related to an
> > ajax inline javascript header contribution (when src attribute is not
> set)
> > https://github.com/sebfz1/wicket-jquery-ui/issues/20
> >
> > In wicket-ajax-jquery.js, #processScript assume that an inline script
> > should be added using Wicket.Head.addJavascript (in opposition to
> > Wicket.Head.addElement
> > for outline script)
> > The problem is that #addJavascript modifies the script content in any
> > case (content
> > = 'try{'+content+'}catch(e){Wicket.Log.error(e);}';), but a script
> element
> > does not necessary contains content that is designed to be executed, that
> > the case of a jQuery Template for instance where the tag signature look
> > like <script id="jquery-template-116997860" type="text/x-jquery-tmpl">
> >
> > I think that #processScript should ensure that the mime type is
> > 'text/javascript' before calling #addJavascript. If the mime type is
> > different, #addElement should be called rather than #addJavascript
> > Another option - if you want to prevent potential issues for user not
> > specifying the script's mime type - could be to bypass scripts (means not
> > calling #addJavascript but #addElement) having their mime type starting
> > with "text/x-", which is a convention for custom script type.
> >
> > Would you like me to open a jira ?
> >
> > Thanks in advance,
> > Sebastien.
> >
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ <http://antiliasoft.com/antilia>
>
Re: Wicket Ajax: Inline script header contribution issue
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi Sebastien,
Wouldn't it be possible to achieve the same with a hidden div?
On Sat, Feb 16, 2013 at 12:39 PM, Sebastien <se...@gmail.com> wrote:
> Dear Wicket's dev team,
>
> A user of wicket-jquery-ui, reported me an issue which is related to an
> ajax inline javascript header contribution (when src attribute is not set)
> https://github.com/sebfz1/wicket-jquery-ui/issues/20
>
> In wicket-ajax-jquery.js, #processScript assume that an inline script
> should be added using Wicket.Head.addJavascript (in opposition to
> Wicket.Head.addElement
> for outline script)
> The problem is that #addJavascript modifies the script content in any
> case (content
> = 'try{'+content+'}catch(e){Wicket.Log.error(e);}';), but a script element
> does not necessary contains content that is designed to be executed, that
> the case of a jQuery Template for instance where the tag signature look
> like <script id="jquery-template-116997860" type="text/x-jquery-tmpl">
>
> I think that #processScript should ensure that the mime type is
> 'text/javascript' before calling #addJavascript. If the mime type is
> different, #addElement should be called rather than #addJavascript
> Another option - if you want to prevent potential issues for user not
> specifying the script's mime type - could be to bypass scripts (means not
> calling #addJavascript but #addElement) having their mime type starting
> with "text/x-", which is a convention for custom script type.
>
> Would you like me to open a jira ?
>
> Thanks in advance,
> Sebastien.
>
--
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>