webtier@glassfish.java.net

Re: JSF 2.0: Errors or Ambiguity in Spec for "onevent" JavaScript Callback

From: <webtier_at_javadesktop.org>
Date: Wed, 30 Sep 2009 06:53:26 PDT

PS The use case of 14.4.1.1 is incorrect.

First, you can't call addOnEvent(statusUpdate) until [b]after[/b] the statusUpdate variable exists. Even it it existed at that point, redefining it later as shown would have no effect because addOnEvent would have the old value.

Second, there is no point in doing var statusUpdate = function statusUpdate.... In JavaScript, doing function foo(...) {...} is the same as doing var foo = function(...) { ... }. So, just do function statusUpdate....

I suggest changing the use case of 14.4.1.1 to this:

function statusUpdate(data) {
  // do something with data.status or other parts of data payload
}
...
jsf.ajax.addOnEvent(statusUpdate);

I also think that this part of the spec should make it a bit more obvious to readers that
<f:ajax ... onevent="statusUpdate" /> invokes addOnEvent.

Cheers-

- Marty
http://www.coreservlets.com
[Message sent by forum member 'martyhall' (hall_at_coreservlets.com)]

http://forums.java.net/jive/thread.jspa?messageID=366335