beginnings of a test component.
[clinton/lisp-on-lines.git] / src / ucw-test-component.lisp
diff --git a/src/ucw-test-component.lisp b/src/ucw-test-component.lisp
new file mode 100644 (file)
index 0000000..b5e3e73
--- /dev/null
@@ -0,0 +1,44 @@
+(in-package :lisp-on-lines)
+
+;;;; LoL CLOS Test Class
+(defclass/meta test-class ()
+  ((test-string :initform "test string" :type string))
+  (:documentation "foo"))
+
+(define-attributes (test-class)
+  (test-string t :label "String :" :editablep t))
+  
+(defcomponent test-component ()
+  ((display-types :accessor display-types :initform (list 'viewer 'editor 'creator 'one-line 'as-string))
+   (current-type :accessor current-type :initform 'viewer)
+   (instance :accessor instance :initform (make-instance 'test-class))))
+
+(defmethod render ((self test-component))
+  (let ((test (instance self))) 
+    (<:h1 (<:as-html "Lisp on Lines Test Component"))
+    (with-component (self)
+      (<ucw:form
+       :action (refresh-component self)
+       (<ucw:select :accessor (current-type self)
+                   (dolist* (type (display-types self))
+                     (<ucw:option :value type (<:as-html type))))
+       (<:input :type "Submit" :value "update")
+       (<:fieldset
+       (<:legend (<:as-html (current-type self)))
+       (display test :type (current-type self)))))
+
+    (<:div
+     (<:h2
+      (<:as-html "UCW Presentation based displays (the old school"))
+     (dolist (type '(:viewer :editor :creator :one-line :as-string))
+       (<:h3 (<:as-html type))
+       (present-view (test type self))
+       (<ucw:a :action (call-view (test type self))
+              (<:as-html "Call to " type))))))
+
+
+(defcomponent standard-display-component ()
+  ((display-function :accessor display-function :initarg :display)))
+
+(defmethod render ((self standard-display-component))
+  (funcall (display-function self) self))
\ No newline at end of file