...
Alternatively, you can add a Wicket label containing JavaScript to your page:
Code Block |
---|
|
<script type="text/javascript" wicket:id="myScript">/* script will be rendered here */</script>
|
Code Block |
---|
|
Label myScript = new Label("myScript", "callWicket();");
myScript.setEscapeModelStrings(false); // do not HTML escape JavaScript code
add(myScript);
|
...
This snippet is taken from a piece of code that makes use of PackageTextTemplate, which is added in the renderHead( component, response ) of AbstractDefaultAjaxBehavior
Code Block |
---|
|
String componentMarkupId = component.getMarkupId();
String callbackUrl = getCallbackUrl().toString();
Map<String, Object> map = new HashMap<>();
map.put( "callbackUrl", callbackUrl );
map.put( "args", "Your Arguments Here" );
map.put( "componentMarkupId", componentMarkupId );
PackageTextTemplate ptt = new PackageTextTemplate( clazz, "resources/main.js" );
OnDomReadyHeaderItem onDomReadyHeaderItem = OnDomReadyHeaderItem.forScript( ptt.asString( map ) );
|
Code Block |
---|
| javascript |
---|
| javascript |
---|
title | JavaScript - Fragment of resources/main.jsjavascript |
---|
|
var wcall = Wicket.Ajax.get({ u: '${callbackUrl}' + '${args}' });
|
Example - Older Versions
Code Block |
---|
| javascript |
---|
| javascript |
---|
title | JavaScriptjavascript |
---|
|
function callWicket() {
var wcall = wicketAjaxGet('$url$' + '$args$', function() { }, function() { });
}
|
...