Paste number 51692: shopping list in UCW

Paste number 51692: shopping list in UCW
Pasted by: grault
When:2 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+13VW
Channel:None
Paste contents:
Raw Source | XML | Display As
(in-package :ucw-user)

(defcomponent shopping-list (simple-window-component)
  ((item-list :accessor item-list :initarg :item-list :initform '())))

(defmethod render ((page shopping-list))
  (dolist (item (item-list page))
    (<:p (<ucw:a :action (remove-item page item) "[X]")
	 (<:as-html " - " item)))
  (let ((new ""))
    (<ucw:form :action (add-item page new)
	       :method "POST"
	       (<ucw:text :accessor new)
	       (<ucw:submit :value "submit" :action (add-item page new)))))

(defaction add-item ((page shopping-list) new)
  (setf (item-list page)
	(sort (adjoin new (item-list page) :test 'equal) #'string<)))

(defaction remove-item :after ((page shopping-list) item)
  (setf (item-list page)
	(remove item (item-list page) :test 'equal)))

(defvar *shopping-application*
  (make-instance 'cookie-session-application :url-prefix "/items/"))

(register-application *default-server* *shopping-application*)

(defentry-point "list.ucw" (:application *shopping-application*)
    ((item-list '()))
  (call 'shopping-list :item-list item-list))


This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.