You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mashleyttu <ma...@gmail.com> on 2015/06/03 15:32:05 UTC

Wicket Atmosphere jQuery noConflict

Our application uses jQuery.noConflict changing all references from $ to $j.
We are trying to integrate Wicket Atmosphere into our application, however,
are running into an issue where it is rendering a $ in an
OnDomReadyHeaderItem.forScript. This is of course causing javascript errors.

We have tracked it down to the renderHead method of AtmosphereBehavior. The
$ is hard coded in the javascript string.

Does anyone know if it is possible to extend AtmosphereBehavior and have
Wicket Atmosphere use our custom version? 

Or it is possible to extend OnDomReadyHeaderItem which would do a replace on
$( with $j( and have wicket use that globally?

Any thoughts on how to resolve this issue? Using Wicket Atmosphere .18 and
Wicket 6.11 currently.

Thanks,
Matt

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Atmosphere-jQuery-noConflict-tp4671046.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket Atmosphere jQuery noConflict

Posted by mashleyttu <ma...@gmail.com>.
Sir, you are a gentleman and a scholar for your quick reply with links to
excellent examples. Thanks so much. You wicket folks think of a solutions
for everything. Love the architecture!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Atmosphere-jQuery-noConflict-tp4671046p4671052.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket Atmosphere jQuery noConflict

Posted by Martin Grigorov <mg...@apache.org>.
Fixed with https://issues.apache.org/jira/browse/WICKET-5917

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

On Wed, Jun 3, 2015 at 5:06 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi,
>
> On Wed, Jun 3, 2015 at 4:32 PM, mashleyttu <ma...@gmail.com> wrote:
>
>> Our application uses jQuery.noConflict changing all references from $ to
>> $j.
>> We are trying to integrate Wicket Atmosphere into our application,
>> however,
>> are running into an issue where it is rendering a $ in an
>> OnDomReadyHeaderItem.forScript. This is of course causing javascript
>> errors.
>>
>> We have tracked it down to the renderHead method of AtmosphereBehavior.
>> The
>> $ is hard coded in the javascript string.
>>
>> Does anyone know if it is possible to extend AtmosphereBehavior and have
>> Wicket Atmosphere use our custom version?
>>
>
> Nope
> See
> https://github.com/apache/wicket/blob/2f0d08d4179af272e1670084ec2e36f58628ff13/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereEventSubscriptionCollector.java#L117
>
>
>>
>> Or it is possible to extend OnDomReadyHeaderItem which would do a replace
>> on
>> $( with $j( and have wicket use that globally?
>>
>
> There is a way!
> You can register custom IHeaderResponseDecorator that will re-write the
> content of OnDomReadyHeaderItem when its script contains "$(".
> See
> http://wicketinaction.com/2012/07/wicket-6-resource-management/
>
> https://github.com/l0rdn1kk0n/wicket-bootstrap/blob/3e6952567976302ed0698de1b52508fc7747e001/bootstrap-samples/src/main/java/de/agilecoders/wicket/samples/WicketApplication.java#L139
>
> https://github.com/l0rdn1kk0n/wicket-bootstrap/blob/3e6952567976302ed0698de1b52508fc7747e001/bootstrap-core/src/main/java/de/agilecoders/wicket/core/markup/html/RenderJavaScriptToFooterHeaderResponseDecorator.java#L81
>
> https://github.com/apache/wicket/blob/2f0d08d4179af272e1670084ec2e36f58628ff13/wicket-core/src/main/java/org/apache/wicket/markup/head/filter/FilteringHeaderResponse.java#L172
> Here you have to do:
> @Override
> public void render(HeaderItem item)
> { if (item instanceof ondomreadyitem &&
> ondomreadyitem.getScript().contains("$("))
> {super.render(OnDomReadyHeaderItem.forScript(item.getScript().replaceAll("$(",
> "jQuery(")))}
>
>
>
>>
>> Any thoughts on how to resolve this issue? Using Wicket Atmosphere .18 and
>> Wicket 6.11 currently.
>>
>
> Please file a ticket so this is fixed for 6.20.
> Thanks!
>
>
>>
>> Thanks,
>> Matt
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Wicket-Atmosphere-jQuery-noConflict-tp4671046.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Wicket Atmosphere jQuery noConflict

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

On Wed, Jun 3, 2015 at 4:32 PM, mashleyttu <ma...@gmail.com> wrote:

> Our application uses jQuery.noConflict changing all references from $ to
> $j.
> We are trying to integrate Wicket Atmosphere into our application, however,
> are running into an issue where it is rendering a $ in an
> OnDomReadyHeaderItem.forScript. This is of course causing javascript
> errors.
>
> We have tracked it down to the renderHead method of AtmosphereBehavior. The
> $ is hard coded in the javascript string.
>
> Does anyone know if it is possible to extend AtmosphereBehavior and have
> Wicket Atmosphere use our custom version?
>

Nope
See
https://github.com/apache/wicket/blob/2f0d08d4179af272e1670084ec2e36f58628ff13/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereEventSubscriptionCollector.java#L117


>
> Or it is possible to extend OnDomReadyHeaderItem which would do a replace
> on
> $( with $j( and have wicket use that globally?
>

There is a way!
You can register custom IHeaderResponseDecorator that will re-write the
content of OnDomReadyHeaderItem when its script contains "$(".
See
http://wicketinaction.com/2012/07/wicket-6-resource-management/
https://github.com/l0rdn1kk0n/wicket-bootstrap/blob/3e6952567976302ed0698de1b52508fc7747e001/bootstrap-samples/src/main/java/de/agilecoders/wicket/samples/WicketApplication.java#L139
https://github.com/l0rdn1kk0n/wicket-bootstrap/blob/3e6952567976302ed0698de1b52508fc7747e001/bootstrap-core/src/main/java/de/agilecoders/wicket/core/markup/html/RenderJavaScriptToFooterHeaderResponseDecorator.java#L81
https://github.com/apache/wicket/blob/2f0d08d4179af272e1670084ec2e36f58628ff13/wicket-core/src/main/java/org/apache/wicket/markup/head/filter/FilteringHeaderResponse.java#L172
Here you have to do:
@Override
public void render(HeaderItem item)
{ if (item instanceof ondomreadyitem &&
ondomreadyitem.getScript().contains("$("))
{super.render(OnDomReadyHeaderItem.forScript(item.getScript().replaceAll("$(",
"jQuery(")))}



>
> Any thoughts on how to resolve this issue? Using Wicket Atmosphere .18 and
> Wicket 6.11 currently.
>

Please file a ticket so this is fixed for 6.20.
Thanks!


>
> Thanks,
> Matt
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-Atmosphere-jQuery-noConflict-tp4671046.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>