You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mats Norén <ma...@gmail.com> on 2008/06/26 07:29:37 UTC
Refresh component from non-wicket js
Hi,
I've been searching the archives on a simple way to repaint a
component from a non-wicket javascript, ie the javascript is not
attached or associated with a wicket component.
The usecase:
1. A user updates data in the browser (non wicket)
2. Presses save (could be a wicket component)
3. An ajax-call is made to update a datasource (non wicket call)
4. Success-handler should repaint a wicket component
In 2 I tried with an AjaxButton and
requestTarget.prependJavascript("doAjaxSaveInOtherLibrary()")..
The problem with that is the timing. The prepended javascript function
returns and then the wicket ajaxcall gets executed before the
success-handler in the non wicket library...
I guess what I'm looking for is a simple way to add a markupcontainer
with an AbstractDefaultAjaxBehavior that I can reference from my non
wicket javascript.
Any suggestions?
/Mats
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Refresh component from non-wicket js
Posted by Martin Funk <ma...@googlemail.com>.
Mats Norén wrote:
> Hi,
> I've been searching the archives on a simple way to repaint a
> component from a non-wicket javascript, ie the javascript is not
> attached or associated with a wicket component.
>
> The usecase:
>
> 1. A user updates data in the browser (non wicket)
> 2. Presses save (could be a wicket component)
> 3. An ajax-call is made to update a datasource (non wicket call)
> 4. Success-handler should repaint a wicket component
>
> In 2 I tried with an AjaxButton and
> requestTarget.prependJavascript("doAjaxSaveInOtherLibrary()")..
>
> The problem with that is the timing. The prepended javascript function
> returns and then the wicket ajaxcall gets executed before the
> success-handler in the non wicket library...
>
> I guess what I'm looking for is a simple way to add a markupcontainer
> with an AbstractDefaultAjaxBehavior that I can reference from my non
> wicket javascript.
>
Hi Mats,
how about this (pseudo code):
componentYouWantToPressOnForSave.add(new AjaxEventBehavior("onclick")
{
protected CharSequence getCallbackScript(boolean
onlyTargetActivePage)
{
return
generateCallbackScript("doAjaxSaveInOtherLibrary('" +
getCallbackUrl(onlyTargetActivePage) +
"'");
}
);
than you can decide if you want to initiate the AjaxCall to the
AjaxEventBehavior or not.
Just call
wicketAjaxGet(callbackUrl)
somewhere in your JavaScript on success-handler.
mf
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org