[Bese-devel] UCW beginners error; it.bese.ucw::place is unbound
Matthew Danish
mdanish at andrew.cmu.edu
Thu Feb 16 20:50:57 UTC 2006
On Wed, Feb 15, 2006 at 09:52:01AM +0000, Andrew Lawson wrote:
> Hello all
> I've been playing with UCW for a day or so but have encountered an error that I can't seem to solve. I'm not sure whether I've not initialised something correctly ot whether I'm simply using the library on an unsupported platform (Lispworks 4.4.6, windows). The error I get is;
>
> The slot IT.BESE.UCW::PLACE is unbound in the object #<IT.BESE.UCW-USER::MY-MODULE-CHOICE 21B457EC> (an instance of class #<IT.BESE.UCW:STANDARD-COMPONENT-CLASS IT.BESE.UCW-USER::MY-MODULE-CHOICE 21A614B4>).
>
> Below is the code that causes this error when you click and it tries to call a new component, I've removed any code that seemed pointless and it still errors as before.
>
> (in-package :it.bese.ucw-user)
>
> (export 'startup)
>
> (defun startup ()
> (asdf:oos 'asdf:load-op :ucw.admin)
> (asdf:oos 'asdf:load-op :ucw.examples)
> (ucw:start-swank)
> (ucw:create-server
> :backend :aserve
> :host "127.0.0.1"
> :port 8080
> :applications (list
> it.bese.ucw-user::*example-application*
> ucw::*admin-application*
> *website-application*)
> :inspect-components nil
> :log-root-directory (make-pathname
> :name nil
> :type nil
> :directory (append (pathname-directory *load-truename*)
> (list :up "logs"))
> :defaults *load-truename*)
> :log-level it.bese.ucw::+info+
> :start-p t))
>
> ;(startup)
>
> (defparameter *website-application*
> (make-instance 'cookie-session-application :url-prefix "/website-application/"))
>
> (defentry-point "index.ucw" (:application *website-application*) ()
> (call 'my-simple-window-component))
>
>
> (defcomponent my-simple-window-component (simple-window-component)
> ()
> (:default-initargs
> :title "My Website"))
(defcomponent my-simple-window-component (simple-window-component)
((body :accessor body :component (my-module-choice)))
(:default-initargs :title "My Website"))
>
> (defmethod initialize-instance :after ((self my-simple-window-component) &rest args)
> (setf (ucw:window-component.stylesheet self) "http://localhost:8080/css/standard.css"))
>
> (defmethod render ((com my-simple-window-component))
> (<:div
> :class "body"
> (<:div
> :class "title"
> (<:div :class "header-1" "Website application"))
> (<:div
> :class "page"
> (render (make-instance 'my-module-choice)))))
(render (body com))
What this achieves is that by using :COMPONENT it automatically sets up
the PLACE and PARENT slots of MY-MODULE-CHOICE. You could do this
without :COMPONENT by doing something like:
(defmethod initialize-instance :after
((c my-simple-window-component) &rest initargs)
(declare (ignore initargs))
(setf (body c) (make-instance 'my-module-choice
:place (make-place (body c)) :parent c)))
I'm no expert, but I'm pretty sure this is all :COMPONENT ends up doing
anyhow. Note that MAKE-PLACE is a macro which accepts a form as
argument, that form being the code which accesses the ``place'' of the
object (in SETF terminology).
Now when you use CALL-COMPONENT, there is a PLACE slot in the old
component for it to bind to the new component.
--
;; Matthew Danish -- user: mrd domain: cmu.edu
;; OpenPGP public key: C24B6010 on keyring.debian.org
More information about the bese-devel
mailing list