jsr344-experts@javaserverfaces-spec-public.java.net

[jsr344-experts] [1050-JavaScriptDelay] PROVISIONALLY CLOSED

From: Ed Burns <edward.burns_at_oracle.com>
Date: Fri, 11 Nov 2011 07:24:05 -0800

When working on JavaJsf (a little side project for a Java VDL), I
noticed that we need some way to throw out all but the most recent ajax
events that have been queued in a short time interval. This is typical
of the case where you are sending one ajax event per keystroke for an
auto-suggest gui, but you only want the thing to start suggesting when
the user pauses a bit from their typing.

I asked our JavaScript expert Werner Punz about it and, naturally, he
said, "oh yeah, I've had that in MyFaces since Willy Brandt was in
office".

So, I filed this issue:

http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1050

I'm marking it PROVISIONALLY CLOSED because I'm happy with the way it
stands now, but I can change it if people here think it needs changing.

You can look at the change to the jsdocs [1] Facelets TLDDocs [2] and
JavaDocs [3] but here's the gist. Add a "delay" attribute with the
following specification.

  If less than delay milliseconds elapses between calls to request()
  only the most recent one is sent and all other requests are
  discarded. The default value of this option is 300. If the value of
  delay is the literal string 'none' without the quotes, no delay is
  used.

On IRC, Werner advocated for the special value '0' instead of 'none' but
I assert the two are different. With '0', you still have a setTimeout()
call, but its delay argument is the numeric 0. This is different from
'none' where there is no setTimeout() call.

Also, some may argue about my making 300 be the default delay. I assert
this is the correct behavior with the 80/20 rule because most times
people do really want a delay.

ACTION: Please kindly request any changes within a week of this email.

Ed

[1] https://maven.java.net/service/local/repositories/snapshots/archive/javax/faces/javax.faces-api/2.2-SNAPSHOT/javax.faces-api-2.2-20111110.224904-25-javadoc.jar/!/jsdocs/symbols/jsf.ajax.html#constructor

[2] https://maven.java.net/service/local/repositories/snapshots/archive/javax/faces/javax.faces-api/2.2-SNAPSHOT/javax.faces-api-2.2-20111110.224904-25-javadoc.jar/!/vdldocs/facelets/f/ajax.html

[3] https://maven.java.net/service/local/repositories/snapshots/archive/javax/faces/javax.faces-api/2.2-SNAPSHOT/javax.faces-api-2.2-20111110.224904-25-javadoc.jar/!/javadocs/javax/faces/component/behavior/AjaxBehavior.html



-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/