public class SomePage {

@Inject
private ComponentResources resources;

@Inject
private JavaScriptSupport javaScriptSupport;

void afterRender(){
   //Create an event link
   Link link = resources.createEventLink("update");
   javaScriptSupport("yourUpdateFunc('%s')", link.toAbsoluteURI());
}

//Handle onUpdate()
Object onUpdate(){
   return new JSONObject(totalPrice, totalPrice);
}

}

//Javascrip[t
function yourUpdateFunc($url){
   //Make an ajax call to $url
   $.ajax($url, function(data){
      update_dom_or_whatever_using_this_json_data(data);
   }
}

Hope it helps

regards
Taha


On Thu, Jan 13, 2011 at 9:30 PM, Mark <mark-li...@xeric.net> wrote:

> >> This lead me to believe that
> >> I could replace: return new MultiZoneUpdate("totalPriceZone",
> >> totalPriceZone);
> >
> > Not correct. The second parameter should be a component or a block. Zone
> and
> > MuitiZoneUpdate are meant to be used without custom written JavaScript.
> >
> >> With something like:
> >> return new JSONObject().put("totalPriceZone", getTotalPrice());
> >> However, it doesn't appear that simply returning the JSON object will
> >> trigger the update on the client side.  Should this work and if not
> >> how can I get a JSONObject to update parts of the page?
> >
> > Just return the JSONObject or JSONObject array directly.
>
> OK, I think that kind of makes sense.  Do you know of any examples of
> this in the Jumpstart, Hotel booking or other example apps that I
> might be able to look at? I have looked and wasn't able to find
> anything.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to