Re: gui +Radio

2008-08-23 Thread Alexander Burger
Hi Tomas,

now I tried some of the proposals I made.

1. We can avoid the group association list completely, if we store a
   '+field' reference into components that are not the group leader.

2. We can directly use the 'radio' function, simplifying the code a
   little

Regarding that, here's a modified version of your '+Radio' class:


(class +Radio +field)
# grp val lbl

# (grp val [lbl])
(dm T (Grp Val Lbl)
   (super)
   (=: grp (field Grp))
   (=: val Val)
   (=: lbl Lbl) )

(dm show (Var)
   (showFld
  (radio
 (ifn (: grp)
Var
(cons '*Gui (: grp id)) )
 (: val)
 (not (able)) ) ) )

(dm set (Val Dn)
   (unless (: grp)
  (super Val Dn) ) )

(dm val ()
   (unless (: grp)
  (super) ) )


I can be called like this:

   (gui '(+Radio) NIL value1a)
   (gui '(+Radio) -1 value1b)
   (gui '(+Radio) -2 value1c)
   ...
   (gui '(+Radio) NIL value2a)
   (gui '(+Radio) -1 value2b)
   (gui '(+Radio) -2 value2c)

So the NIL argument indicates a group leader. For other group members,
you can pass a standard field specifier (i.e. a numeric field offset or
an alias symbol) as expected by the built-in 'field' function.

With aliases for the group leaders, the above example would be:

   (gui 'group1 '(+Radio) NIL value1a)
   (gui '(+Radio) 'group1 value1b)
   (gui '(+Radio) 'group1 value1c)
   ...
   (gui 'group2 '(+Radio) NIL value2a)
   (gui '(+Radio) 'group2 value2b)
   (gui '(+Radio) 'group2 value2c)


One downer remains, though: As I suspected, lib/form.js does not work
with radio buttons. I'll have to check that separately.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Re: gui +Radio

2008-08-23 Thread Alexander Burger
Actually, the 'set' and 'val' methods are also not needed.

The reduces '+Radio' to:

(class +Radio +field)
# grp val lbl

# (grp val [lbl])
(dm T (Grp Val Lbl)
   (super)
   (=: grp (field Grp))
   (=: val Val)
   (=: lbl Lbl) )

(dm show (Var)
   (showFld
  (radio
 (ifn (: grp)
Var
(cons '*Gui (: grp id)) )
 (: val)
 (not (able)) ) ) )


Still it all hangs on the JavaScript problem ...
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]


Re: gui +Radio

2008-08-22 Thread Alexander Burger
Hi Tomas,

though I did not find the time yet to try your +Radio component, I'd
like to touch on two points:

 ## to be the first for HTML rendering and return NIL value.  *Radio
 ## must be set to NIL before a form is rendered.
 
 (default *Radio NIL)

1. (default .. NIL) has no effect, (off *Radio) might be more
   appropriate. But the actual problem I see is using a global variable.
   The difficult question is *when* to clear that variable, so that it
   works also when the page is reloaded (possibly with a different
   status and layout), when the browser back-button is pressed, or
   during JavsScript postings.

   I think the right way to go would be to have '1st' be the main
   component of that radio group, where you can pass an offset like -1,
   -2 etc. in the 'T' method. Each +gui component has an 'id' property
   that can be used for such arithmetics (so you don't have to use
   (length (get *Top 'gui))).

2. Why do you distinguish in the 'show' method between directly calling
   'radio', and a hand-made version?

(ifn (: 1st)
   (radio Var (: xval) (not (able)))
   (prin input type=\radio\ name=\*Gui(+
...

   Is there some subtle difference?

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]