Well, after looking at that code I saw a few things that seemed
wrong.

1. If you want to render a link that starts a flow, use lambda/cc to
signal cl-cont to do its job.
2. Don't ignore the args in your render-link lambda, that's where the
continuation parameter k gets passed (details not important, unless
I'm totally mistaken!).
3. For preference, I do not use lambda's with flows. A simple widget
is always better imho, because it takes care of the continuation-
passing without having to futz around with K parameters (for the
continuation) since widgets store continuations in a slot. There's a
previous post regarding flows/continuations that has some code on
paste.lisp.org -- it may help to look at that too.

> I use the back button on the second widget, then click on the action
> link and see the second widget again.

IMO this should not be possible. The action link should have nothing
to do with the widget that was declared as part of a navigation (ie,
the 2nd widget).

This is what I tried:

1. Nav with two children 1st and 2nd.
2. 1st has a link for a with flow, yielding 3rd.

Results:

Flowing from 1st to 3rd works. Going to 2nd and using back button
brings one back to the 1st widget (whether in a state of having flowed
out to 3, or pre-flow).

The code is below, but since I'm on the old version of weblocks
(before nav and composites change) perhaps my code will be confusing,
so caveat lector.

Also, here's a short screencast showing what happens in the browser.
It's divided at the point I realized there needed to be a return from
widget 3 (back button does not work to return from continuations) and
oh, the CSS is screwed up. Nav menu is the stuff under "LaGru".

Code:


(defun init-user-session (comp)
  (setf (composite-widgets comp)
        (let ((main-nav (make-instance 'main-navigation :name
"LaGru")))
           (init-navigation main-nav
                         'First (make-first)
                         'Second (make-widget 2))
           (wrap-in-composite  main-nav))))

(defun make-first ()
  (let ((w (make-instance 'composite)))
    (setf (composite-widgets w)
          (list (make-widget 1)         ; OK this works
                (make-instance 'simple-widget
                               :render-fn
                               (f_
                                 (with-html
                                   (render-link (lambda/cc (&rest args)
                                                  (with-flow _
                                                    (yield 
(make-answering-widget 3))))
                                                "Third"))))))
    w))


(defun make-answering-widget (arg)
  (make-instance 'simple-widget
                 :render-fn
                 (f_
                   (with-html (str (format nil "This is widget ~A " arg))
                              (when (widget-continuation _)
                                (render-link (f_% (answer _))
                                             " (return from cont) "))))))

(defun make-widget (arg)
  (make-simple-message-2 (format nil "ARGE ~A" arg)))

(defun make-simple-message-2 (astr)
  (make-instance 'simple-widget
                 :render-fn (closure (with-html (:div :class "error" (str 
astr))))))


(defwidget simple-widget ()
  ((var :accessor get-var :initarg :var)
   (render-fn :accessor render-fn :initarg :render-fn :initform
(constantly nil))))

(defmethod render-widget-body ((widget simple-widget) &rest args)
  (funcall (render-fn widget) widget))

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"weblocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/weblocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to