hi,
- your component has to implement IHeaderContributor, that's where the
response-object gets passed
- you add the abstractdefaultajaxbehavior to the component you'd like to
call from javascript. you then have to override the respond method of
AbstractDefaultAjaxBehavior to perform your actions and to append your
changes to the response
e.g. in your panel
final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior()
{
protected void respond(final AjaxRequestTarget target) {
target.add(new Label("foo", "yeah I just called this from flash!"));
}
};
add(behave);
the method behave.getCallbackUrl(); gives you the url to call that respond
method. I.e. if you paste the String returned from that method into your
browser, you'll invoke the respond method, the same applies for the
javascript method
- Dojopackagedtexttemplate is part of the wicketstuff dojo project, don't
know if you need more than that class or if it's possible without the
project. we used that as part of the wicketstuff-push project ... add this
to your pom:
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-dojo</artifactId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
Michael
Pills wrote:
>
>
> Michael Sparer wrote:
>>
>> Generally you can get the callback-url of a wicket ajax-component with
>> calling getCallbackUrl(), you should have a look at wicketAjaxGet which
>> is part of wicket's JS library
>>
>>
>> to make the whole stuff a bit more dynamic you could make a javascript
>> template using wicketstuff-dojo, e.g.
>>
>> function callWicket() {
>> var wcall = wicketAjaxGet('${url}' + addToUrl, function() { },
>> function() { }); // addToUrl are optional parameters
>> }
>>
>> and then in the java-code
>> HashMap<String, String> map = new HashMap<String, String>();
>>
>> map.put("url", getCallbackUrl().toString()); // getcallbackurl
>> is from
>> AbstractAjaxBehavior
>> return new DojoPackagedTextTemplate(YourClass.class,
>> "CometdDefaultBehaviorTemplate.js")
>> .asString(map);
>>
>> and then add it in your responseheader (renderHead method) with
>> response.renderJavaScript(...)
>>
>> this may be not the easiest method but allows the most flexibility.
>>
>> hope that helps
>>
>> Michael
>>
>
> Hello Michael,
>
> thank you for your answer.
>
> I have two little problems with this way:
> - how can I get an instance of ResponseHeader from a WebPage?
> - I need to use an AbstractAjaxBehavior, but where do I need to add it?
> Simply on the page? Or on my ShockwaveComponent?
>
>
> Thank you ;)
>
> EDIT: And I find no class named "DojoPackagedTextTemplate"... is it
> included in a wicket's subproject?
>
-----
Michael Sparer
http://talk-on-tech.blogspot.com
--
View this message in context:
http://www.nabble.com/Javascript-call-to-wicket-tp14685384p14693821.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]