Author: achiumenti Date: Tue Apr 15 01:02:25 2008 New Revision: 38
Modified: trunk/doc/chapters/writing-components.texinfo trunk/main/claw-core/src/hunchentoot-overrides.lisp Log: user manual update
Modified: trunk/doc/chapters/writing-components.texinfo ============================================================================== --- trunk/doc/chapters/writing-components.texinfo (original) +++ trunk/doc/chapters/writing-components.texinfo Tue Apr 15 01:02:25 2008 @@ -63,7 +63,8 @@ So a call to the constructor function of our new fresh component might have this shape: @cartouche @lisp -(site-template> :title "this is the page title" :class "foo" +(site-template> :title "this is the page title" + :class "foo" (p> Hello world)) @end lisp @@ -94,4 +95,45 @@ Ouch, this is nearly what we expected, but it seems there are two extraneous tags, do you see them?
They are the meta and the script tags. -...continue... + +The meta tag is inserted by the @code{HTHEAD} component, that we have instantiated with @code{HEAD>}. +The value of the content attribute, is taken from the @code{PAGE-CONTENT-TYPE} slot method, whose default is @code{HUNCHENTOOT:*DEFAULT-CONTENT-TYPE*}. + +The script tag is used when @value{claw} components want to inject their instance javascripts. +So, for example, we could create a component that, when clicked, it shows a js alert containing the html +component of another component: + +@cartouche +@lisp +(defcomponent inspector () ()) + +(defmethod wcomponent-parameters ((inspector inspector)) + (list :id :required :ref-id :required)) + +(defmethod wcomponent-template ((inspector inspector)) + (div> :static-id (htcomponent-client-id inspactor) + (htcomponent-body o))) + +(defmethod htcomponent-instance-initscript ((inspector inspector)) + (format nil "document.getElementById('~a').onclick = + function () @{alert(document.getElementById('~a').innerHTML);@};" + (htcomponent-client-id inspector) + (wcomponent-parameter-value inspector :ref-id))) + +@end lisp +@end cartouche + +Ok, now we can use our new inspector component inside our page: + +@cartouche +@lisp +(defmethod page-content ((some-page some-page)) + (let ((hidden-component-id (generate-id "hidden")) + (rnd-value (prin1-to-string (random 10000))) + (site-template> :title "this is the page title" + :class "foo" + (p> + (div> :static-id hidden-component-id rnd-value) + (inspector> :id "inspector" "Show value")))))) +@end lisp +@end cartouche
Modified: trunk/main/claw-core/src/hunchentoot-overrides.lisp ============================================================================== --- trunk/main/claw-core/src/hunchentoot-overrides.lisp (original) +++ trunk/main/claw-core/src/hunchentoot-overrides.lisp Tue Apr 15 01:02:25 2008 @@ -171,10 +171,10 @@ realm))) (when *reply* (cond ((null session) - (log-message :notice "No session for session identifier '~A' (User-Agent: '~A', IP: '~A', REALM: '~A')" + (log-message :notice "No session for session identifier '~A' (User-Agent: '~A', IP: '~A', REALM: '~A')" session-identifier user-agent remote-addr realm)) (t - (log-message :warning "Fake session identifier '~A' (User-Agent: '~A', IP: '~A', REALM: '~A')" + (log-message :warning "Fake session identifier '~A' (User-Agent: '~A', IP: '~A', REALM: '~A')" session-identifier user-agent remote-addr realm)))) (when session (remove-session session))