dev@jsf-extensions.java.net

Re: [Fwd: Request for presentation: DynaFaces]

From: Ed Burns <ed.burns_at_sun.com>
Date: Thu, 20 Jul 2006 09:31:04 -0700

Adding jsf-extensions dev list to CC.

> When using an ajaxZone, can I have only one event in there? Sometimes
> inside an ajaxZone tag I could have a few events that would need the
> subview to be updated. If I had a listbox for example I could have
> three events:

> a) double click on a list element
> b) pressing enter after selecting a list element
> c) the regular onchange event when a different row is selected...

> Can I fit something like this in a single "eventType" attibute? If not
> how would I accommodate this scenario?

The AjaxZone approach only allows one type of JavaScript event to be
co-opted for use by DynaFaces. For example, "I want to co-opt the
'onclick' event for a subset of the HTML elements within this zone to
cause an AJAX transaction to occurr". If you want to co-opt more than
one event type, on different elements, you'll have to use Faces.Event or
Faces.Command directly.

You can use the ajaxZone approach and the Faces.Event/Faces.Command
approach together, by the way. For example, consider your inspectElement
hook.

This hook returns true or false depending on whether or not you want the
element ajaxified per the requirements you have listed as attributes on
your ajaxZone tag. Let's say you're ajaxifying for the "onclick" event
in the ajaxZone tag, but there are some elements you want to ajaxify
for the "ondoubleclick" event. Your inspectElementHook will look
something like this:

function inspectElement(element) {

  // Look at element, if it's to be ajaxified with the regular "onclick"
  // just return true. Otherwise, see if it's to be ajaxified with
  // "ondoubleclick". If so, perform the ajaxification manually, and
  // return false.

  var options = new Object();
  options.render = // client ids to re-render
  var c = new Faces.Command(element, "doubleclick", options);

  return false;
}

Ed