[Bese-devel] Re: UCW beginners error; it.bese.ucw::place is unbound
Marco Baringer
mb at bese.it
Fri Feb 17 13:08:32 UTC 2006
Andrew Lawson wrote:
> (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"))
>
> (defmethod initialize-instance :after ((self my-simple-window-component) &rest args)
> (setf (ucw:window-component.stylesheet self) "http://localhost:8080/css/standard.css"))
fwiw, these three forms can be reduced to:
(defcomponent my-simple-window-component (simple-window-component)
()
(:default-initargs
:title "My Website"
:stylesheet "http://localhost:8080/css/standard.css")
(:entry-point "index.ucw" (:application *website-application*)))
> (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)))))
here's your problem. components need to initialized in a special manor,
the place slot must be set to something and the parent, continuation and
calling-component slots should generally be set. all of this is done
transparently if you use the :component initarg to defcomponent:
(defcomponent my-simple-window-component (simple-window-component)
((page :accessor page
:component (my-module-choice)))
(:default-initargs
:title "My Website"
:stylesheet "http://localhost:8080/css/standard.css")
(:entry-point "index.ucw" (:application *website-application*)))
and change call to render in your render method to this:
(render (page com))
> (defcomponent my-module-choice (widget-component)
> ())
>
> (defmethod render ((self my-module-choice))
> (<:div
> :class "header-4"
> "Module choice")
> (<:p "Choose the module you would like to use")
> (<ucw:a :action (open-module self 'first-module)
> (<:as-html "Open first module")))
>
> (defaction open-module ((self my-module-choice) module-type)
> (call-component self (make-instance module-type)))
this is exactly the same as:
(defaction open-module ((self my-module-choice) module-type)
(call module-type))
but, imho, more idomatic.
> (defcomponent first-module (widget-component)
> ())
>
> (defmethod render ((self first-module))
> (<:div
> :class "header-4"
> "First module"))
hth.
--
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
-Leonard Cohen
More information about the bese-devel
mailing list