user interfaces for samba4 or samba3 configuration

derrell at derrell at
Mon Sep 4 18:50:02 GMT 2006

"S P" <sree314 at> writes:

> On 9/4/06, derrell at <derrell at> wrote:
>> Yes, it is a bit messy-looking, but that's javascript.  You may be able to
>> clean things up a bit by not using anonymous functions: name your functions
>> and pass the name to the event handlers.  Just watch your closures to ensure
>> that your functions get freed properly when they go out of scope and are no
>> longer needed.  (
> I'd like to do this:
> txtBox.onclick = somefn()
> and have somefn() access to all the UI components and their values,
> not just txtBox.
> For this, somefn will need to be somewhere where it has scope access
> to all the other component variables. That, in my code, is inside the
> functions that generate the UI. If I had  a single variable (say of
> the main window), on which I could do this like:
> mainWindow.txtBox.getValue() or
> mainWindow.getComponent("txtBox").getValue()
> then life would be easy, and code cleaner :), since only mainWindow
> needs to be passed around.

There have been calls for an object dictionary to use for this purpose.  I
believe it's in the future plans.  You'd then be able to look up the various
objects you require from your event handler, using the dictionary.

> I have used these examples and tests quite a lot. But they all seem to
> follow the same design of assigning functions to events (i.e. inline),
> and have trivial inline functions, so they're not of much help.

The principles still apply, though.  See if generating named functions makes
your code any cleaner.  You'll still have a function within a function, but at
least you're not trying to write a whole (anonymous) function as a parameter
to a call to AddEventListener().


More information about the samba-technical mailing list