gwl-president-table.gdl 1.08 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
(in-package :gwl-user)

(define-object president ()
  :input-slots
  (name term))

;; http://localhost:9000/make?object=gwl-user::presidents
(define-object presidents (base-ajax-sheet)
  :input-slots
  ((data (list (list :name "Carter" :term 1976)
               (list :name "Reagan" :term 1980)
               (list :name "Bush" :term 1988)
               (list :name "Clinton" :term 1992))))

  :objects
  ((presidents :type 'president
               :sequence (:size (length (the data)))
               :name (getf (nth (the-child index) (the data)) :name)
               :term (getf (nth (the-child index) (the data)) :term)))

  :computed-slots
  ((main-sheet-body
    (with-cl-who-string (:indent t)
      (htm
       (:p (:c (:h3 (fmt "Info on ~a Presidents:"
                         (length (list-elements (the presidents)))))))
       ((:table :border 1)
        (:tr (:th "Name") (:th "Term"))
        (dolist (president (list-elements (the presidents)))
          (htm      
           (:tr (:td (str (the-object president name)))
                (:td (str (the-object president term))))))))))))