[Bese-devel] Some issues

Mariano Montone marianomontone at gmail.com
Sat Oct 6 22:31:21 UTC 2007


Hello!

I've been having some issues with UCW lately. Maybe someone can help me out.

1) Component initialization

Have some problems embedding components which require initialization
parameters that are not available.

Example: I would like to do the following:

(defcomponent welcome-component (simple-window-component)
  ((menu :accessor welcome-component.menu :component
     (standard-menu :title "Operaciones"
            :items
            `(("Requests" .  ,(lambda () (switch-component (
welcome-component.body <reference to welcome-component instance being
created>) 'requests)))))
...

But the welcome-component instance is not available and at the same time the
'items' initform is required. Besides, I have to indicate that the menu slot
is a component, so I have to instance something there. Am I correct?

So, when this happens (and this is happenning quite often), I do:
(defcomponent welcome-component (simple-window-component)
  ((menu :accessor welcome-component.menu :component
     (standard-menu :title "" :items nil))              <--- I DO THIS JUST
TO SAY I HAVE A COMPONENT IN MENU, maybe there's a better way
   )

and then:

(defmethod initialize-instance :after ((comp welcome-component) &key)
  (setf (welcome-component.menu comp)
     (make-instance 'standard-menu :title "Sections"
            :items
            `(("Clients" .  ,(lambda () (switch-component (
welcome-component.body comp) 'clients)))))))

where I can access the welcome-component instance through the 'comp symbol.

Maybe you can give me some advise about better idiom here.

2) Iterate and macrolet problems (binding issues)

Sometimes some symbols seem to  be unbound when I use iterate or macrolet.
In general, I can fix that using lambda, but maybe you know why that happens
and how to fix it.

Examples:
This won't work:

(:render ()
        (<:p (<:as-html (menu.title standard-menu)))
        (<:ul
        (iter
          (for (item-name .  item-func) in (menu.items standard-menu))
             (<ucw:a :action (funcall item-func) (<:as-html item-name))))))

because item-func does not get bound when referring it from the <ucw:a
action.

The replacement:
  (:render ()
        (<:p (<:as-html ( menu.title standard-menu)))
        (<:ul
         (mapcar  #'(lambda (item)
              (destructuring-bind (item-name . item-func) item
                (<ucw:a :action (funcall item-func) (<:as-html item-name))))

              (menu.items standard-menu)))))

And then it works.

Same problem and solution with macrolet.

3) Have a problem with this piece of code:
         (<ucw:a :action (funcall item-func) (<:as-html item-name)))

The problem is that item-func is suppossed to be a cc/function, so I guess
that won't work if the item-func is doing something cc/related like calling
other component.

So my question is: Is there any way of creating a lambda/cc? And how could I
call it from the
<ucw:a :action ?

Note that I'm having issues and I am *assumming* that that is the problem
(as I'm switching a container component from inside item-func and it doesn't
work), but I don't really know.

If I'm correct, then I would love to provide a lambda/cc construct to the
client.

Well, that's all :)

Thank you very much!

Mariano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20071006/24bb4f23/attachment.html>


More information about the bese-devel mailing list