user1273256
user1273256

Reputation:

How to call a javascript through wicket framework ?

Hi I am new to wicket framework, I need to create a context menu so that when I right my context menu should be displayed instead of browser menu. The following is the Javascript code of my context menu in Dojo:

<script src='dojo/dojo.js' data-dojo-config='async: false, parseOnLoad: true'></script>

Now my question is how to call this same javascript through wicket. As I am getting error when I am trying to right the code in my java file to call this javascript

private static final CompressedResourceReference DOJO_JS    = new CompressedResourceReference(HomePage.class,"./dojo/dojo/dojo.js" data-dojo-config="async: false, parseOnLoad: true");

Upvotes: 0

Views: 277

Answers (1)

Nicktar
Nicktar

Reputation: 5575

You need to escape your " so java can tell what's part of your String and what's not... Additionally you need to add and remove "s where needed. The CompressedResourceReference-Constructor expects one Scope and one String. So that's what you have to provide...

private static final CompressedResourceReference DOJO_JS    = new CompressedResourceReference(HomePage.class,"./dojo/dojo/dojo.js data-dojo-config=\"async: false, parseOnLoad: true\"");

Upvotes: 1

Related Questions