Yes, I had trouble with this when I was first learning Weblocks also.
WITH-HTML doesn't return a string; it writes HTML to the output stream. So
calling it to supply the :CONTENT argument doesn't work. Similarly for
RENDER-LINK.
But you can use functions as widgets; the function will be invoked during
rendering, which is the right time to render HTML and links. So, for
example:
(defun make-test-page ()
(make-instance 'widget :children
(list ... (lambda () (render-link ...)) ... )))
Oh, and you don't need to use DEFUN/CC unless you're doing something really
complicated. I've written quite a substantial app without ever using it.
-- Scott
On Mon, Apr 2, 2012 at 2:10 AM, Rayslava <[email protected]> wrote:
> Hello.
> I'm investigating weblocks now and just figured out such a thing:
>
> (defun make-about-page ()
> (make-instance 'widget :children
> (list
> (make-instance 'string-widget :content
> "About page"))))
>
> (defun make-test-page ()
> (make-instance 'widget :children
> (list
> (make-instance 'string-widget :content
> "test")
> (make-instance 'string-widget :content
> (with-html (str (render-link (lambda (&rest
> args)
> (declare (ignore args))
> (do-page #'make-test-page))
> "test page"
> :ajaxp nil))))
> (make-instance 'string-widget :content
> "test2"))))
>
> (defun/cc make-other-page (k)
> (make-instance 'string-widget :content
> (with-html (:p "Other Page")
> (:p (render-link (lambda (&rest args)
> (declare (ignorable args))
> (answer k))
> "Go Back")))))
>
> (defun make-main-page ()
> (make-instance 'widget :children
> (list
> (make-navigation "Main Menu"
> (list "About" (make-about-page) "about")
> (list "Companies" (make-test-page) "test")))))
>
> (defun init-user-session (root)
> (with-flow root
> (yield (make-main-page))))
>
> And "test page" link just doesn't appear.
> Running results into
>
> <div class='widget string-widget' id='dom2'>
> <p>test</p>
> </div>
> <div class='widget string-widget' id='dom3'>
> <p></p>
> </div>
> <div class='widget string-widget' id='dom4'>
> <p>test2</p>
> </div>
>
> The only strange thing is the output when I load the file:
>
> * (load "/home/ray/projects/localsite/src/layout.lisp")
> <a href='/about?action=4027%3A9A51E3C66D4DB032E3C3ABE5145C46AD'>test
> page</a>
> T
> * (reset-sessions)
> *
>
> That looks like render-page has wrong output stream. Could I do
> something with it?
>
> --
> 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.
>
>
--
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.