Hi Adam,

first of all: welcome to the qooxdoo project!

On Friday 06 November 2009 Adam Steffen wrote:
> Using qooxdoo, I made a class to hold the data, and added member functions
> that will update the data set, based on passed variables.  I then created
>  an interface window with all the widgets. What I want to do is associate
>  the member functions of the data set with listeners of the corresponding
>  widgets.  My simple brain would like to do the following:
> 
> In window interface class:
> * ...
>     mycheckboxgroup.addListener("changeSelection",
> myDataSet.updateFunction(data_name,mycheckboxgroup), myDataSet);
>  ...*
> 
> Then in data set class:
> * ...
>     updateFunction : function(data_name,checkbox)
>     {
>         value = checkbox.getSelected().getValue();
>         this.setData(data_name,value);
>      }
>  ...*
> 
> Is there a way to create a generic listener function that takes variable
> arguments?  I don't want to have to write the code for each new listener
> function for each of the 50 checkboxgroups i have, but I want to add a
> listner to each and associate that listener to a data set based on a
> variable.
I assume that the variable "data_name" holds data which is connected to each 
checkbox group.

You can use the following snippet to achieve this

--snip--
mycheckboxgroup.setUserData("data_name", "your_data");
mycheckboxgroup.addListener("changeSelection", myDataSet.updateFunction, 
myDataSet);

...

updateFunction : function(e)
{
  var checkbox = e.getTarget();
  var data_name = checkbox.getUserData("data_name");
  value = checkbox.getSelected().getValue();
  this.setData(data_name,value);
}
--snip--

This way you can use a single update method. 

I hope, I understood your problem right :)

cheers,
  Alex

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to