[Bese-devel] passing form inputs directly to actions
Marco Baringer
mb at bese.it
Sun Feb 27 11:42:08 UTC 2005
i discovered this 'trick' a while ago and i figured i'd share it:
genrally all the inputs of a form are tied to slots in a component
like so:
(defcomponent my-form ()
((input :accessor input)))
(defmethod render-on ...
...
(<ucw:input :accessor (input component))
...
(<ucw:input :type "submit" :action (whatever c))
)
(defaction whatever ((c component))
(do-stuyf-with-input (input c)))
often we'd have a component whose slots served only to hold the values
of the form. this always looked kind of ugly and i kept trying to find
some way to work around it, here it is:
(defcomponent my-form ()
())
(defmethod render-on ...
...
(let ((input ""))
(<ucw:input :accessor input)
...
(<ucw:input :type "submit" :action (whatever c input))))
(defaction whatever ((c component) input)
(do-stuff-with-input input))
using this trick we get slightly cleaner componnets (no "place holder"
slots) at the expense of backtracking. more often the not this is a
good trade off.
--
-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