Bruno Dumon wrote:

I've just added the instance based event listeners. You can both add and
remove them.

Following table summarizes the current event situation, see below for
more info.

                   valuechanged   action
field                   Y           N/A
multivaluefield         (*)         N/A
booleanfield            Y           N/A
repeater                N/A         N/A
output                  N/A         N/A
submit                  N/A         Y
action                  N/A         Y
repeater-action         N/A         Y
row-action              N/A         Y
aggregatefield          (**)        N/A
upload                  N/A         N/A
messages                N/A         N/A

N/A means not applicable

For those events where Y (yes) is mentioned, they are supported both in
the definition and the instance.



I'd like to add "action" on every widget where a @submit-on-change makes sense (field, booleanfield, multivaluefield, upload). This would allow to have some specific event-handling related to the fact that the widget was activated, regardless if its value changed or not.


And then the special cases:

(*) multivaluefield: the builder happily builds the listeners, but
multivaluefield seems to nowhere create events. So I haven't added
instance-based event listeners on that widget either. -> solution I see
is to add full support for value changed events to this widget.

(**) aggregatefield: the definition and definition builder don't support
value changed events, and events are hence also nowhere created, but
since the instance class extends from Field it automatically has the
possibility to add instance-level event listeners (but they won't ever
be called) -> solution: unsure. Is it possible/meaningful to support
value changed listeners on this widget? Volunteers?

- o -

And now the practical side: example usage in flowscript:

form.getWidget("test").addActionListener(newActionListener(function(event) {
       print("hi there");
}));

where the newActionListener function is as follows:

function newActionListener(listenerFunction) {
   var listener = {actionPerformed: listenerFunction };
   var adapter = new
JavaAdapter(Packages.org.apache.cocoon.forms.event.ActionListener,
listener);
   return adapter;
}

Question: do we add these newActionListener and newValueChangedListener
functions to the (javascript) form object, or as separate functions next
to it?



It could also be an additional method of ScriptableWidget, which would take care of the adaptation.


Sylvain

--
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }



Reply via email to