I added this callback on both add and remove functions, but when I add row
I get this error appearing on top of the windows :
"Communication with the server failed: TypeError: undefined is not a
function".

And it doesn't do it when the callback is done by the remove call. If there
were a problem loading js file it would have complained on it too. Am i
missing something ?


2014-08-07 11:41 GMT+02:00 Chung Khanh Duy <chungkhanhduy1...@gmail.com>:

> Hi,
>
> Sorry I put some wrong code @_@. The java code should be as below:
>
> ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
> @Override
>  public void run(JavaScriptSupport javascriptSupport) {
> javascriptSupport.addScript('callUpdateZone()");
> }
> });
>
> You have to  import
> org.apache.tapestry5.services.javascript.JavaScriptSupport;
>
> Thanks,
> Duy.
>
>
>
>
> On Thu, Aug 7, 2014 at 4:37 PM, squallmat . <squall...@gmail.com> wrote:
>
> > thanks for your answer Chung, I tried it but when i add a row I got this
> > error :
> >
> > No object of type
> > org.apache.tapestry5.services.javascript.JavaScriptSupport is available
> > from the Environment.
> >
> >
> > 2014-08-07 10:08 GMT+02:00 Chung Khanh Duy <chungkhanhduy1...@gmail.com
> >:
> >
> > > Hi,
> > >
> > > You could not call updating zone in onAddRow or onRemove(). This is my
> > way
> > > to do that:
> > >
> > > 1. Declare one action link in tml file:
> > >
> > > <t:actionlink t:id="updateZoneLink"
> > > t:clientId="updateZoneLink"
> > > t:zone="zoneTitle"
> > >  style="display:none"/>
> > > 2. in Java code, we callback a javascript function
> > >
> > > onRemoveRow....() {
> > > ....
> > >  javascriptSupport.addScript("callUpdateZone()");
> > >
> > > }
> > >
> > > Object onActionFromUpdateZoneLink() {
> > >  // update your zone
> > > return request.isXHR() ? zoneTitle.getBody() : null;
> > > }
> > >
> > > 3. In your js file, you have to define callUPdateZone() method:
> > >
> > > this.callUpdateZone = function() {
> > > // send ajax to update zone
> > > var $link = $("a[clientid*='updateZoneLink']");
> > >  var href = $link.attr('href');
> > > if (href.indexOf('?') != -1) {
> > > href = href.substr(0, href.indexOf('?'));
> > >  }
> > > Tapestry.findZoneManager($link[0]).updateFromURL(href);
> > > }
> > >
> > > Hopefully it can help. Notice I used javascript Jquery. You can use
> > > prototype to find your DOM element.
> > >
> > > Thanks,
> > > Duy.
> > >
> >
>
>
>
> --
> Chung Khánh Duy
> Project Support Manager
> Formos
>

Reply via email to