[claw-cvs] r159 - in trunk/main: claw-demo/src/frontend/components claw-html.dojo/src claw-html/src
Andrea Chiumenti
achiumenti at common-lisp.net
Thu Dec 18 07:46:23 UTC 2008
Author: achiumenti
Date: Thu Dec 18 07:46:23 2008
New Revision: 159
Log:
bugfixes and initscripts methods renaming
Modified:
trunk/main/claw-demo/src/frontend/components/edit-customer.lisp
trunk/main/claw-demo/src/frontend/components/pager.lisp
trunk/main/claw-demo/src/frontend/components/redirect.lisp
trunk/main/claw-html.dojo/src/djbody.lisp
trunk/main/claw-html.dojo/src/djform.lisp
trunk/main/claw-html.dojo/src/djwidget.lisp
trunk/main/claw-html/src/packages.lisp
trunk/main/claw-html/src/tags.lisp
Modified: trunk/main/claw-demo/src/frontend/components/edit-customer.lisp
==============================================================================
--- trunk/main/claw-demo/src/frontend/components/edit-customer.lisp (original)
+++ trunk/main/claw-demo/src/frontend/components/edit-customer.lisp Thu Dec 18 07:46:23 2008
@@ -70,7 +70,7 @@
when val
return t))))
-(defmethod htcomponent-class-initscripts :around ((obj edit-customer))
+(defmethod htcomponent-global-initscripts :around ((obj edit-customer))
(let ((req-function (ps:ps (defun is-address-field-required (container-id)
(defvar input-list (dojo.query "[widgetId]" (dojo.by-id container-id)))
(defvar result false)
@@ -99,7 +99,7 @@
(lambda (input-widget) (setf (slot-value input-widget 'required) false))))))))))
(append (list req-function address-field-validation) (call-next-method))))
-(defmethod htcomponent-instance-initscript :around ((obj edit-customer))
+(defmethod htcomponent-initscripts :around ((obj edit-customer))
(let* ((component-id (htcomponent-client-id obj))
(parent-script (call-next-method))
(script (ps:ps* `(progn
Modified: trunk/main/claw-demo/src/frontend/components/pager.lisp
==============================================================================
--- trunk/main/claw-demo/src/frontend/components/pager.lisp (original)
+++ trunk/main/claw-demo/src/frontend/components/pager.lisp Thu Dec 18 07:46:23 2008
@@ -82,7 +82,7 @@
(div> :class "button last"
(span> :on-click (set-offset-value pager count-pages) "last"))))))))
-(defmethod htcomponent-class-initscripts ((pager pager))
+(defmethod htcomponent-global-initscripts ((pager pager))
(let ((update-component-id (pager-update-component-id pager))
(page-size (pager-page-size pager)))
(list
Modified: trunk/main/claw-demo/src/frontend/components/redirect.lisp
==============================================================================
--- trunk/main/claw-demo/src/frontend/components/redirect.lisp (original)
+++ trunk/main/claw-demo/src/frontend/components/redirect.lisp Thu Dec 18 07:46:23 2008
@@ -34,7 +34,7 @@
:reader redirect-href))
(:metaclass metacomponent))
-(defmethod htcomponent-instance-initscript ((redirect redirect))
+(defmethod htcomponent-initscripts ((redirect redirect))
(ps:ps* `(location.replace ,(redirect-href redirect))))
(defmethod wcomponent-template ((redirect redirect))
Modified: trunk/main/claw-html.dojo/src/djbody.lisp
==============================================================================
--- trunk/main/claw-html.dojo/src/djbody.lisp (original)
+++ trunk/main/claw-html.dojo/src/djbody.lisp Thu Dec 18 07:46:23 2008
@@ -108,7 +108,7 @@
(htcomponent-body obj)
(djxcontent-pane> :static-id id
(script> :type "text/javascript"
- (page-body-init-scripts pobj))))))
+ (page-body-initscripts pobj))))))
(defmethod wcomponent-after-prerender ((obj djbody) (pobj page))
Modified: trunk/main/claw-html.dojo/src/djform.lisp
==============================================================================
--- trunk/main/claw-html.dojo/src/djform.lisp (original)
+++ trunk/main/claw-html.dojo/src/djform.lisp Thu Dec 18 07:46:23 2008
@@ -55,7 +55,7 @@
(subseq js-array 0 (1- (length js-array))))))))))
-(defmethod htcomponent-instance-initscript ((obj djform))
+(defmethod htcomponent-initscripts ((obj djform))
nil)
(defclass djtext-box (cinput djwidget)
@@ -283,7 +283,7 @@
:editor editor
(wcomponent-informal-parameters obj))))
-(defmethod htcomponent-instance-initscript((obj djinline-edit-box))
+(defmethod htcomponent-initscripts((obj djinline-edit-box))
(let ((id (htcomponent-client-id obj))
(page-url (claw-script-name)))
(ps* `(dojo.connect (dijit.by-id ,id)
Modified: trunk/main/claw-html.dojo/src/djwidget.lisp
==============================================================================
--- trunk/main/claw-html.dojo/src/djwidget.lisp (original)
+++ trunk/main/claw-html.dojo/src/djwidget.lisp Thu Dec 18 07:46:23 2008
@@ -57,7 +57,7 @@
(defmethod djwidget-formal-parameters ((djwidget djwidget))())
-(defmethod htcomponent-class-initscripts ((obj djwidget))
+(defmethod htcomponent-global-initscripts ((obj djwidget))
(let ((dojo-type (djwidget-dojo-type obj))
(dojo-require (djwidget-dojo-require obj)))
(append
Modified: trunk/main/claw-html/src/packages.lisp
==============================================================================
--- trunk/main/claw-html/src/packages.lisp (original)
+++ trunk/main/claw-html/src/packages.lisp Thu Dec 18 07:46:23 2008
@@ -57,11 +57,11 @@
#:page-req-parameter
#:page-script-files
#:page-stylesheet-files
- #:page-class-initscripts
- #:page-instance-initscripts
+ #:page-global-initscripts
+ #:page-initscripts
#:page-initstyles
#:page-current-component
- #:page-body-init-scripts
+ #:page-body-initscripts
#:htcomponent
#:htcomponent-page
#:htcomponent-body
@@ -70,8 +70,8 @@
#:htcomponent-real-id
#:htcomponent-script-files
#:htcomponent-stylesheet-files
- #:htcomponent-class-initscripts
- #:htcomponent-instance-initscript
+ #:htcomponent-global-initscripts
+ #:htcomponent-initscripts
#:htcomponent-initstyles
#:tag
#:tag-name
Modified: trunk/main/claw-html/src/tags.lisp
==============================================================================
--- trunk/main/claw-html/src/tags.lisp (original)
+++ trunk/main/claw-html/src/tags.lisp Thu Dec 18 07:46:23 2008
@@ -108,17 +108,17 @@
- REST The format arguments
See http://www.lisp.org/HyperSpec/Body/fun_format.html#format for more info."))
-(defgeneric page-body-init-scripts (page)
+(defgeneric page-body-initscripts (page)
(:documentation "During the render phase wcomponent instances inject their initialization scripts (javascript)
that will be evaluated when the page has been loaded.
-This internal method is called to render these scripts. The result is used by the HTBODY-INIT-SCRIPTS-TAG method
+This internal method is called to render these scripts. The result is used by the HTBODY-INITSCRIPTS-TAG method
that generates a <script> tag that will be appended at the end of the <body> tag (generated by the BODY> function
tag.
- PAGE is the page instance that must be given"))
-(defgeneric htbody-init-scripts-tag (page &optional on-load)
+(defgeneric htbody-initscripts-tag (page &optional on-load)
(:documentation "Encloses the init inscance scripts injected into the page into a <script> tag component
-See PAGE-BODY-INIT-SCRIPTS form more info. If the ON-LOAD parameter it not nil, then the script will be executed
+See PAGE-BODY-INITSCRIPTS form more info. If the ON-LOAD parameter it not nil, then the script will be executed
on the onload document event.
- PAGE is the page instance that must be given"))
@@ -285,6 +285,11 @@
`(let ((,var ,form))
(when ,var , at body)))
+(defmacro listify (var)
+ `(if (listp ,var)
+ ,var
+ (list ,var)))
+
(defun flatten (tree &optional result-list)
"Traverses the tree in order, collecting even non-null leaves into a list."
(let ((result result-list))
@@ -393,10 +398,10 @@
:accessor page-script-files :documentation "Holds component class scripts files injected by components during the request cycle")
(stylesheet-files :initarg :stylesheet-files
:accessor page-stylesheet-files :documentation "Holds component class css files injected by components during the request cycle")
- (class-initscripts :initarg :class-initscripts
- :accessor page-class-initscripts :documentation "Holds component class javascript directives injected by components during the request cycle")
- (instancee-initscripts :initarg :instance-initscripts
- :accessor page-instance-initscripts :documentation "Holds component instance javascript directives injected by components during the request cycle")
+ (global-initscripts :initarg :global-initscripts
+ :accessor page-global-initscripts :documentation "Holds component class javascript directives injected by components during the request cycle")
+ (initscripts :initarg :initscripts
+ :accessor page-initscripts :documentation "Holds component instance javascript directives injected by components during the request cycle")
(initstyles :initarg :initstyles
:accessor page-initstyles :documentation "Holds component class and instance stylesheet directives injected by components during the request cycle")
(indent :initarg :indent
@@ -440,8 +445,8 @@
:script-files nil
:json-component-count 0
:stylesheet-files nil
- :class-initscripts nil
- :instance-initscripts nil
+ :global-initscripts nil
+ :initscripts nil
:initstyles nil
:indent t
:tabulator 0
@@ -486,12 +491,12 @@
:accessor htcomponent-script-files :documentation "Page injectable script files")
(stylesheet-files :initarg :stylesheet-files
:accessor htcomponent-stylesheet-files :documentation "Page injectable css files")
- (class-initscripts :initarg :class-initscripts
- :accessor htcomponent-class-initscripts :documentation "Page injectable javascript class derectives")
- (instance-initscript :initarg :instance-initscript
- :accessor htcomponent-instance-initscript :documentation "Page injectable javascript instance derectives")
+ (global-initscripts :initarg :global-initscripts
+ :accessor htcomponent-global-initscripts :documentation "Page injectable javascript class derectives")
+ (initscripts :initarg :initscript
+ :accessor htcomponent-initscripts :documentation "Page injectable javascript instance derectives. It may be a string or a list of strings")
(initstyles :initarg :initstyles
- :accessor htcomponent-initstyles :documentation "Component injectable css derectives"))
+ :accessor htcomponent-initstyles :documentation "Component injectable css derectives. It may be a string or a list of strings"))
(:default-initargs :page nil
:body nil
:json-render-on-validation-errors-p nil
@@ -501,8 +506,8 @@
:render-condition nil
:script-files nil
:stylesheet-files nil
- :class-initscripts nil
- :instance-initscript nil
+ :global-initscripts nil
+ :initscripts nil
:initstyles nil)
(:documentation "Base class for all other claw components"))
@@ -709,7 +714,7 @@
(when injection
(htcomponent-render injection page)))
(page-format-raw page "\",instanceInjections:\"")
- (let ((init-scripts (htbody-init-scripts-tag page)))
+ (let ((init-scripts (htbody-initscripts-tag page)))
(when init-scripts
(htcomponent-render init-scripts page)))
(page-format-raw page "\",errors:")
@@ -719,8 +724,8 @@
(page-format-raw page "}")
(page-format-raw page (page-json-suffix page)))))
-(defmethod page-body-init-scripts ((page page))
- (when-let (init-scripts (reverse (page-instance-initscripts page)))
+(defmethod page-body-initscripts ((page page))
+ (when-let (init-scripts (reverse (page-initscripts page)))
(format nil "~{~a~%~}" init-scripts)))
(defmethod page-print-tabulation ((page page))
@@ -738,7 +743,7 @@
(defmethod page-init-injections ((page page))
(let ((tag-list)
- (class-init-scripts (format nil "~{~a~%~}" (reverse (page-class-initscripts page))))
+ (class-init-scripts (format nil "~{~a~%~}" (reverse (page-global-initscripts page))))
(init-styles (format nil "~{~a~%~}" (reverse (page-initstyles page)))))
(unless (string= "" class-init-scripts)
(let ((current-js (script> :type "text/javascript")))
@@ -1117,15 +1122,15 @@
((null child-tag) nil)
(t (htcomponent-render child-tag page)))))
(when (page-can-print page)
- (when-let (init-script-tag (htbody-init-scripts-tag page t))
+ (when-let (init-script-tag (htbody-initscripts-tag page t))
(htcomponent-render init-script-tag page))
(tag-render-endtag htbody page))
(when (or (page-can-print page) previous-print-status)
(setf (page-can-print page) nil)
(htcomponent-json-print-end-component htbody)))))
-(defmethod htbody-init-scripts-tag ((page page) &optional on-load)
- (when-let (scripts (page-body-init-scripts page))
+(defmethod htbody-initscripts-tag ((page page) &optional on-load)
+ (when-let (scripts (page-body-initscripts page))
(let ((js (script> :type "text/javascript"))
(js-control-string (if on-load
"
@@ -1266,9 +1271,11 @@
css-files
(list css-files)))
(pushnew css (page-stylesheet-files page) :test #'equal)))
- (dolist (js (htcomponent-class-initscripts wcomponent))
- (pushnew js (page-class-initscripts page) :test #'equal))
- (dolist (style (htcomponent-initstyles wcomponent))
+ (dolist (js (htcomponent-global-initscripts wcomponent))
+ (pushnew js (page-global-initscripts page) :test #'equal))
+ (dolist (js (listify (htcomponent-initscripts wcomponent)))
+ (pushnew js (page-initscripts page) :test #'equal))
+ (dolist (style (listify (htcomponent-initstyles wcomponent)))
(pushnew style (page-initstyles page) :test #'equal)))
(if (listp template)
(dolist (tag template)
More information about the Claw-cvs
mailing list