[cl-who-devel] Pre-filled forms
Adam Thorsen
adam.thorsen at gmail.com
Wed Mar 29 16:23:43 UTC 2006
I'm using TBNL in a small web-app. A common need when developing webapps is
to display a form with fields pre-populated from the database (i.e. email
address, street address, etc.).
I'm wondering if it's possible to do this with cl-who in some generic way?
I thought perhaps I could customize cl-who using the
convert-tag-to-string-list method. The function below overrides default
handling of (:input) tags to look for a :tuple attribute with a value set to
a hash containing the values from the database needed to pre-fill the form
the input element is part of. This approach doesn't work, however, because
convert-tag-to-string serializes the string at compile time, and the data
needs to be retrieved from the database at run time. Any ideas?
(defmethod convert-tag-to-string-list ((tag (eql :input)) attr-list body
body-fn)
;;(declare (ignore attr-list))
(let ((name (cdr (assoc :name attr-list)))
(type (cdr (assoc :type attr-list)))
(tuple (eval (cdr (assoc :tuple attr-list)))))
(nconc (cons (format nil "<input name='~a' type='~a' value='~a'>"
name type (if tuple
(gethash name tuple)
""))
(funcall body-fn body)) (list "</input>"))))
Thanks,
-Adam Thorsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-who-devel/attachments/20060329/2515838e/attachment.html>
More information about the Cl-who-devel
mailing list