[Bese-devel] simple-form question

hbabcockos1 at mac.com hbabcockos1 at mac.com
Sat Jul 22 01:35:55 UTC 2006


Hello,

I'm trying to create forms as needed to get values from the user, but  
have run into the following puzzling behavior:

This doesn't work: (I get the error message "The variable FORM- 
TEST::FORM1 is unbound" when I click on the submit button)

(defcomponent form1 (simple-form)
   ((field1 :accessor field1
	   :initform (make-instance 'string-field :input-size 10))))

(defcomponent form-test (simple-window-component)
   ((content :accessor content
	    :initform nil)
    (result :accessor result
	   :initform nil))
   (:default-initargs
     :title "Form Test"
     :content-type "text/html; charset=utf-8;"
     :javascript nil))

(defaction handle-form-1 ((session form-test) (form form1))
   (setf (result session) (value (field1 form1)))
   (setf *debug* (result session)))

(defmethod render ((session form-test))
   (let ((the-form (make-instance 'form1)))
     (<ucw:simple-form :action (handle-form-1 session the-form)
		      :method "POST"
		      (<:p (render (field1 the-form)))
		      (<:p (<:submit :value "Submit")))))


However, this works:

(defcomponent form-test (simple-window-component)
   ((content :accessor content
	    :initform (make-instance 'form1))
    (result :accessor result
	   :initform nil))
   (:default-initargs
     :title "Form Test"
     :content-type "text/html; charset=utf-8;"
     :javascript nil))

(defaction handle-form-1 ((session form-test))
   (setf (result session) (value (field1 (content session))))
   (setf *debug* (result session)))

(defmethod render ((session form-test))
   (let ((the-form (content session)))
     (<ucw:simple-form :action (handle-form-1 session)
		      :method "POST"
		      (<:p (render (field1 the-form)))
		      (<:p (<:submit :value "Submit")))))


But this doesn't work: (I again get the error message "The variable  
FORM-TEST::FORM1 is unbound" when I click on the submit button)

(defcomponent form-test (simple-window-component)
   ((content :accessor content
	    :initform (make-instance 'form1))
    (result :accessor result
	   :initform nil))
   (:default-initargs
     :title "Form Test"
     :content-type "text/html; charset=utf-8;"
     :javascript nil))

(defaction handle-form-1 ((session form-test) (form form1))
   (setf (result session) (value (field1 form1)))
   (setf *debug* (result session)))

(defmethod render ((session form-test))
   (let ((the-form (content session)))
     (<ucw:simple-form :action (handle-form-1 session the-form)
		      :method "POST"
		      (<:p (render (field1 the-form)))
		      (<:p (<:submit :value "Submit")))))


This is with SBCL 0.9.12 & a ~3 week old ucw boxset.

Do I have to store all my forms in slots in the main window  
component? Or have I made some other mistake?

thanks,
-Hazen




More information about the bese-devel mailing list