cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject Re: cforms: events on widget instances
Date Fri, 30 Apr 2004 14:29:40 GMT
On Fri, 2004-04-30 at 16:10, Vadim Gritsenko wrote:
> Bruno Dumon wrote:
> 
> >On Fri, 2004-04-30 at 14:30, Vadim Gritsenko wrote:
> >  
> >
> >>Sylvain Wallez wrote:
> >>
> >>    
> >>
> >>>Bruno Dumon wrote:
> >>>      
> >>>
> >>...
> >>
> >>    
> >>
> >>>>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.
> >>>      
> >>>
> >>Agreed. And syntax should become then simply:
> >>
> >>form.getWidget("test").addActionListener(function(event) {
> >>       print("hi there");
> >>});
> >>    
> >>
> >
> >Saw my message about the v3 api?
> >  
> >
> 
> Saw but have not read yet - just got cable internet setup yesterday ;-)
> 
> 
> >there I've implemented it as:
> >
> >form.model.test.onActivate = function() { print("hi there"); }
> >
> >which is still more readable and (I think) flexible enough.
> >
> 
> Does it support more than one listener? Not that I need it right away, 
> but addActionListener implies more than one listener, where "onActivate 
> =" implies just one (setter semantic).

yep that's right, it only supports one. I think that for the flowscript
integration this is good enough, and it makes it somewhat simpler to
read and understand.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


Mime
View raw message