Lisp and Hunchentoot newbie here. I haven't been able to find an answer to the following question by searching the existing archives. I have a very substantial application written in PHP and MYSQL and would love to convert it over to Lisp using Hunchentoot and CL-SQL. My question is that I can't find anything to indicate how I can capture something like an onClick or an onLoad event using the keyword notation provided by Hunchentoot. I noticed from the test demo for the easy handler example that hitting the enter key while on a text box will cause the form to be submitted but I can't see where in the code this is explicitly called for.
Any clarification or assistance would be most appreciated.
Bill Tate wrote:
how I can capture something like an onClick or an onLoad event using the keyword notation provided by Hunchentoot.
onclick and other on-something events happen on the client, in the browser. Hunchentoot lives on the server side and therefore has nothing to with those events. If you really want to receive those events on the server you'll have to generate some Javascript to capture the events and, for example, make the call to the server using AJAX.
I noticed from the test demo for the easy handler example that hitting the enter key while on a text box will cause the form to be submitted but I can't see where in the code this is explicitly called for.
This behaviour is built into forms.
Cheers, Ury Marshak
I apologize if this is a stupid question, but this is driving me nuts. I'm doing a simple test to get acquainted with Hunchentoot and CL-WHO. I need to do the typical navigate to form page ->fill out the form and submit form -> go to a different response page. Handlers for both form and response pages have been defined.
I've tried to set an :action attribute on the form to go to the desired response page as you would in normal HTML. However, I keep getting the original form page when hitting submit button. I'm obviously missing something here. Here's a snippet of the form page
(define-easy-handler (my-demo-form :uri "/hunchentoot/test/my-demo-form.html" :default-request-type :post) (person city state) (with-html (:html (:head (:title "Simple Form Response Example")) (:body (:h2 "Test Form ") (:p (:form :method :post :action "/Hunchentoot/test/my-demo-response.html" (:table :border 1 :cellpadding 2 :cellspacing 0 (:tr .....
Any help would be appreciated.
On 3/16/07, Bill Tate wdtate@comcast.net wrote:
I apologize if this is a stupid question, but this is driving me nuts. I'm doing a simple test to get acquainted with Hunchentoot and CL-WHO. I need to do the typical navigate to form page ->fill out the form and submit form -> go to a different response page. Handlers for both form and response pages have been defined.
I've tried to set an :action attribute on the form to go to the desired response page as you would in normal HTML. However, I keep getting the original form page when hitting submit button. I'm obviously missing something here. Here's a snippet of the form page
(define-easy-handler (my-demo-form :uri "/hunchentoot/test/my-demo-form.html" :default-request-type :post) (person city state) (with-html (:html (:head (:title "Simple Form Response Example")) (:body (:h2 "Test Form ") (:p (:form :method :post :action "/Hunchentoot/test/my-demo-response.html" (:table :border 1 :cellpadding 2 :cellspacing 0 (:tr .....
Any help would be appreciated.
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
What does your dispatch table look like? (in particular, does it have an entry for /hunchentoot/test/my-demo-response.html - I'm assuming that's the target page?) Rob
Uggh - forgot to add it. Thanks - I'll test it out.
Thanks much
-----Original Message-----
What does your dispatch table look like? (in particular, does it have an entry for /hunchentoot/test/my-demo-response.html - I'm assuming that's the target page?) Rob
_______________________________________________ tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
I noticed from the test demo for the easy handler example that hitting the enter key while on a text box will cause the form to be submitted but I can't see where in the code this is explicitly called for.
A lot of html objects (like <a> <input>, etc) have default action associated with them.
So even if you bind a onclick handler to the <a href=...> tag to do some interesting stuff, but unless your handler explicitly instructs the browser to prevent the default action from taking place, it will redirect to the href target after your handler is finished executing.
The enter key behavior that you described above also triggers a browser default action (submitting the form), so if you don't want that, you need to bind a custom handler and use it to prevent the default behavior.
"Javascript the definitive guide" is a very good tutorial and reference if you want to learn more about this.
My question is that I can't find anything to indicate how I can capture something like an onClick or an onLoad event using the keyword notation provided by Hunchentoot.
I think you're referring to cl-who, not hunchentoot.
I'm not sure if this answers your question, but setting a onclick handler for a tag is just a matter of assigning the corresponding attribute.
(cl-who:with-html-output (out *standard-output*) (:a :href "target.html" :onclick "javascript:myFunc(); return false;" "Click Me"))
=>
<a href='target.html' onclick='javascript:myFunc(); return false;'>Click Me</a>
Of couse, you still need to define the javascript function myFunc(), either by including a js file or embedding it in the cl-who form (cl-interprol is of great help here) or even use the parentscript library so you can write it in lisp too!
HTH, -- Mac
(cl-who:with-html-output (out *standard-output*) (:a :href "target.html" :onclick "javascript:myFunc(); return false;" "Click Me"))
Basically this is what I was looking for. I assumed it was some kind of keyword association for events associated with specific html forms but I wasn't terribly sure what the syntax would be or its format. After looking at your response, I should have known - always seem to get that feeling after using LISP :>)
Thanks very much for the help.