;;;; -*- lisp -*- (in-package :it.bese.ucw-user) ;;;; the file uploading example and test (defclass file-upload-example (widget-component template-component) ((file :accessor file-upload-example.file :initform "")) (:metaclass standard-component-class) (:default-initargs :template-name "ucw/examples/upload.tal") (:documentation "Form for uploading a file.")) (defaction upload ((form file-upload-example)) (call 'file-upload-viewer :file-data (file-upload-example.file form))) (defclass file-upload-viewer (widget-component) ((file-data :initarg :file-data)) (:metaclass standard-component-class) (:documentation "View a file uplodaed by the file-upload-example component.")) (defmethod render ((viewer file-upload-viewer)) (<:table (<:tr (<:th "Header") (<:th "Value")) (dolist* ((name . value) (mime-part-headers (slot-value viewer 'file-data))) (<:tr (<:td (<:as-html name)) (<:td (<:as-html value))))) (<:p "Body:") (<:pre (<:as-html (mime-part-body (slot-value viewer 'file-data)))) (