[Bese-devel] checkboxes
Marco Baringer
mb at bese.it
Thu Mar 31 07:57:31 UTC 2005
Julian Stecklina <der_julian at web.de> writes:
> (defmethod render-on ((res response) (range pic-range-select))
> (<ucw:form
> (<:table
> (loop
> for item in (items range)
> do (<:tr
> (<:td
> (render-range-select-item range item))
> (<:td
> (<ucw:input :type "checkbox"
> :accessor (gethash item (hash range)))))))
> (<ucw:input :type "submit" :action (range-select range))))
i always get this wrong too, and i don't know of a "good" fix. the
problem here is that :accessor uses a closure. (gethash item (hash
range)) closes over range, whcih is good, and item, but loop does not
create a new binding over each iteration, it merly modifies the
current binding. try this:
(defmethod render-on ((res response) (range pic-range-select))
(<ucw:form
(<:table
(loop
for item in (items range)
do (<:tr
(<:td
(render-range-select-item range item))
(<:td
;; create a fresh binding of item for every checkbox
(let ((item item))
(<ucw:input :type "checkbox"
:accessor (gethash item (hash range))))))))
(<ucw:input :type "submit" :action (range-select range))))
--
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
-Leonard Cohen
More information about the bese-devel
mailing list