[Bese-devel] How to return multiple values from a form...
Ties Stuij
cjstuij at gmail.com
Wed May 17 21:46:26 UTC 2006
> Hello.
he
> A newbie question.
> (defentry-point "index.ucw" (:application *chessweb-app*) ()
> (loop
> (multiple-value-bind (pgn-title pgn-string) (call 'pgn-publisher)
> (call 'create-html-pgn :pgn-title pgn-title :pgn-string pgn-string))))
well, first of all, defentrypoint always functions as a loop, second,
if you call pgn from create-html-pgn and you answer, you come back to
create-html-pgn. So you can define defentry-point like this:
(defentry-point "index.ucw" (:application *chessweb-app*) ()
(call 'pgn-publisher))
>
> (defcomponent pgn-publisher (simple-window-component)
> ()
> (:default-initargs :title "ChessWeb Publisher"))
>
> (defmethod render ((window pgn-publisher))
> (<:h1 "ChessWeb Publisher")
> (let ((pgn-title "")
> (pgn-string ""))
> (<ucw:form :action (ok window pgn-string)
> (<:as-html "PGN Page Title: ")
> (<ucw:input :accessor pgn-title)
> (<:br)
> (<ucw:textarea :accessor pgn-string :rows 10 :cols 64)
> (<:br)
> (<:submit :value "Publish"))))
here you pass only pgn-string to the ok action which takes only one
argument while you also want to pass pgn-title. Or so i prosume
because you wanted to catch them both with a multiple-value-bind in
the defentry-point. Anyway, lets just make a defaction:
(defaction to-html-pgn ((w pgn-publisher) title string)
(call 'create-html-pgn :pgn-title title :pgn-string string))
and call it from the png-publisher render method:
...
(pgn-string ""))
(<ucw:form :action (to-html-pgn window pgn-title pgn-string)
(<:as-html "PGN Page Title: ")
...
>
> (defcomponent create-html-pgn (simple-window-component)
> ((pgn-title :accessor pgn-title :initarg :pgn-title)
> (pgn-string :accessor pgn-string :initarg :pgn-string))
> (:default-initargs :title "ChessWeb Page"))
>
> (defmethod render ((window create-html-pgn))
> (<:h1 (pgn-title window))
> (<:as-html (pgn-string window)) (<:br) (<:br)
> (<ucw:a :action (ok window) "Back"))
and in the render method above you forgot to (<:as-html.. the title:
(defmethod render ((window create-html-pgn))
(<:h1 (<:as-html (pgn-title window)))
(<:as-html (pgn-string window)) (<:br) (<:br)
(<ucw:a :action (ok window) "Back"))
Well that works for me anyway, hope it helps.
greets,
Ties
More information about the bese-devel
mailing list