On Jan 13, 2009, at 9:35 PM, John Ours wrote:

On Jan 14, 2009, at 12:11 AM, Chuck Hill wrote:


On Jan 12, 2009, at 7:24 AM, John Ours wrote:

Hi All,

Quick question about the Ajax Slider component in Wonder. What is the rationale behind the OnChangeServer binding? The behavior seems to be that if the binding is set - regardless of its value - an ajax post occurs to set the value. A quick peek at the source confirms that's what's going on...and the value of the binding is being ignored. Was this the intended behavior and I'm missing something? Or would this binding be better expressed as a boolean?


The binding is supposed to return a JavaScript snippet to be run in the browser after the slider changes.



Thanks Chuck.  How does OnChangeServer differ from OnChange then?

onChange is static JavaScript, it does not make a trip to the server. onChangeServer sends the current slider position/value back to the server and has the application dynamically generate the JavaScript to return to and execute on the client.


In the SliderExample from the Wonder project, they use OnChange and OnSlide for the client javascript, like this:

AjaxSlider1: AjaxSlider {
        orientation = "horizontal";
        value = 10;
        minimum = 0;
        maximum = 10;
        onSlide = "function(v) {$('value').innerHTML = v}";
        onChange = "function(v) {$('value').innerHTML = v}";
}

In particular I'm curious about this piece of code (and a similar one for onSlideServer) from AjaxSlider.java:

       if(hasBinding("onChangeServer")) {
        String parent = (String) valueForBinding("onChange");
options.setObjectForKey("function(v) {new Ajax.Request('"+ AjaxUtils.ajaxComponentActionUrl(context()) +"', {parameters: '"+context().elementID()+"=' + v + '&ajaxSlideTrigger=onChange'})" +(parent != null ? "; var parentFunction = " + parent + "; parentFunction(v);" : "")
                        +"}", "onChange");
       } else {
new AjaxOption("onChange", AjaxOption.SCRIPT).addToDictionary(this, options);
       }


Does that code make more sense with the above explanation?

Chuck


--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to