I'm a Lisp newbie trying to use the jquery ui sortable widget ( http://api.jqueryui.com/sortable/) to sort a list of tasks. The plugin posts the list of tasks as:
1. task[]: 37 2. task[]: 36 3. task[]: 38
Which Hunchentoot sees as: [2013-02-09 11:15:34 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
However, when I use this handler: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) (tasks) (task-prioritize tasks))
I get: [2013-02-09 11:38:52 [DEBUG]] task-prioritize NIL
[2013-02-09 11:38:52 [DEBUG]] parameters ((task[] . 36) (task[] . 38) (task[] . 37))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'array)) (task-prioritize tasks)) I get: [2013-02-09 11:36:07 [DEBUG]] task-prioritize #()
[2013-02-09 11:36:07 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'list)) (task-prioritize tasks)) I get: [2013-02-09 11:37:32 [DEBUG]] task-prioritize NIL
[2013-02-09 11:37:32 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
My understanding from the documentation is that I should end up with a list of id's in the var task when is all said and done. Could someone tell me what I'm doing wrong that that isn't happening? Or help clarify my understanding?
Thanks so much!
the parameter name is "task[]", not "tasks" used as a default name for the 'tasks' parameter in the easy handler.
try using real-name
HiH
Ala'a
On Sat, Feb 9, 2013 at 10:42 PM, Jim Barrows jim.barrows@gmail.com wrote:
I'm a Lisp newbie trying to use the jquery ui sortable widget (http://api.jqueryui.com/sortable/) to sort a list of tasks. The plugin posts the list of tasks as:
task[]: 37 task[]: 36 task[]: 38
Which Hunchentoot sees as: [2013-02-09 11:15:34 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
However, when I use this handler: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) (tasks) (task-prioritize tasks))
I get: [2013-02-09 11:38:52 [DEBUG]] task-prioritize NIL
[2013-02-09 11:38:52 [DEBUG]] parameters ((task[] . 36) (task[] . 38) (task[] . 37))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'array)) (task-prioritize tasks)) I get: [2013-02-09 11:36:07 [DEBUG]] task-prioritize #()
[2013-02-09 11:36:07 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'list)) (task-prioritize tasks)) I get: [2013-02-09 11:37:32 [DEBUG]] task-prioritize NIL
[2013-02-09 11:37:32 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
My understanding from the documentation is that I should end up with a list of id's in the var task when is all said and done. Could someone tell me what I'm doing wrong that that isn't happening? Or help clarify my understanding?
Thanks so much!
James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
Fixed that, and it didn't work. I went through all three permutations (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((task :parameter-type 'list)) (task-prioritize task))
results in: [2013-02-09 12:18:40 [DEBUG]] task-prioritize NIL
[2013-02-09 12:18:40 [DEBUG]] parameters ((task[] . 37) (task[] . 38) (task[] . 36))
On Sat, Feb 9, 2013 at 11:47 AM, Ala'a Mohammad amalawi@gmail.com wrote:
the parameter name is "task[]", not "tasks" used as a default name for the 'tasks' parameter in the easy handler.
try using real-name
HiH
Ala'a
On Sat, Feb 9, 2013 at 10:42 PM, Jim Barrows jim.barrows@gmail.com wrote:
I'm a Lisp newbie trying to use the jquery ui sortable widget (http://api.jqueryui.com/sortable/) to sort a list of tasks. The plugin posts the list of tasks as:
task[]: 37 task[]: 36 task[]: 38
Which Hunchentoot sees as: [2013-02-09 11:15:34 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
However, when I use this handler: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) (tasks) (task-prioritize tasks))
I get: [2013-02-09 11:38:52 [DEBUG]] task-prioritize NIL
[2013-02-09 11:38:52 [DEBUG]] parameters ((task[] . 36) (task[] . 38) (task[] . 37))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'array)) (task-prioritize tasks)) I get: [2013-02-09 11:36:07 [DEBUG]] task-prioritize #()
[2013-02-09 11:36:07 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'list)) (task-prioritize tasks)) I get: [2013-02-09 11:37:32 [DEBUG]] task-prioritize NIL
[2013-02-09 11:37:32 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
My understanding from the documentation is that I should end up with a
list
of id's in the var task when is all said and done. Could someone tell me what I'm doing wrong that that isn't happening? Or help clarify my understanding?
Thanks so much!
James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
You're still not using the parameter name "task[]".
Try: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((task[] :parameter-type 'list)) (task-prioritize task[]))
-Matt
On Sat, Feb 9, 2013 at 2:19 PM, Jim Barrows jim.barrows@gmail.com wrote:
Fixed that, and it didn't work. I went through all three permutations (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((task :parameter-type 'list)) (task-prioritize task))
results in: [2013-02-09 12:18:40 [DEBUG]] task-prioritize NIL
[2013-02-09 12:18:40 [DEBUG]] parameters ((task[] . 37) (task[] . 38) (task[] . 36))
On Sat, Feb 9, 2013 at 11:47 AM, Ala'a Mohammad amalawi@gmail.com wrote:
the parameter name is "task[]", not "tasks" used as a default name for the 'tasks' parameter in the easy handler.
try using real-name
HiH
Ala'a
On Sat, Feb 9, 2013 at 10:42 PM, Jim Barrows jim.barrows@gmail.com wrote:
I'm a Lisp newbie trying to use the jquery ui sortable widget (http://api.jqueryui.com/sortable/) to sort a list of tasks. The plugin posts the list of tasks as:
task[]: 37 task[]: 36 task[]: 38
Which Hunchentoot sees as: [2013-02-09 11:15:34 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
However, when I use this handler: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) (tasks) (task-prioritize tasks))
I get: [2013-02-09 11:38:52 [DEBUG]] task-prioritize NIL
[2013-02-09 11:38:52 [DEBUG]] parameters ((task[] . 36) (task[] . 38) (task[] . 37))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'array)) (task-prioritize tasks)) I get: [2013-02-09 11:36:07 [DEBUG]] task-prioritize #()
[2013-02-09 11:36:07 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'list)) (task-prioritize tasks)) I get: [2013-02-09 11:37:32 [DEBUG]] task-prioritize NIL
[2013-02-09 11:37:32 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
My understanding from the documentation is that I should end up with a list of id's in the var task when is all said and done. Could someone tell me what I'm doing wrong that that isn't happening? Or help clarify my understanding?
Thanks so much!
James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
-- James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
that worked. It never hit me that the name of the variable could include the square brackets. Very cool! Thanks!
On Sat, Feb 9, 2013 at 12:34 PM, Matthew Curry mjcurry@gmail.com wrote:
You're still not using the parameter name "task[]".
Try: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((task[] :parameter-type 'list)) (task-prioritize task[]))
-Matt
On Sat, Feb 9, 2013 at 2:19 PM, Jim Barrows jim.barrows@gmail.com wrote:
Fixed that, and it didn't work. I went through all three permutations (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((task :parameter-type 'list)) (task-prioritize task))
results in: [2013-02-09 12:18:40 [DEBUG]] task-prioritize NIL
[2013-02-09 12:18:40 [DEBUG]] parameters ((task[] . 37) (task[] . 38) (task[] . 36))
On Sat, Feb 9, 2013 at 11:47 AM, Ala'a Mohammad amalawi@gmail.com
wrote:
the parameter name is "task[]", not "tasks" used as a default name for the 'tasks' parameter in the easy handler.
try using real-name
HiH
Ala'a
On Sat, Feb 9, 2013 at 10:42 PM, Jim Barrows jim.barrows@gmail.com wrote:
I'm a Lisp newbie trying to use the jquery ui sortable widget (http://api.jqueryui.com/sortable/) to sort a list of tasks. The plugin posts the list of tasks as:
task[]: 37 task[]: 36 task[]: 38
Which Hunchentoot sees as: [2013-02-09 11:15:34 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
However, when I use this handler: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) (tasks) (task-prioritize tasks))
I get: [2013-02-09 11:38:52 [DEBUG]] task-prioritize NIL
[2013-02-09 11:38:52 [DEBUG]] parameters ((task[] . 36) (task[] . 38) (task[] . 37))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'array)) (task-prioritize tasks)) I get: [2013-02-09 11:36:07 [DEBUG]] task-prioritize #()
[2013-02-09 11:36:07 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'list)) (task-prioritize tasks)) I get: [2013-02-09 11:37:32 [DEBUG]] task-prioritize NIL
[2013-02-09 11:37:32 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
My understanding from the documentation is that I should end up with a list of id's in the var task when is all said and done. Could someone tell me what I'm doing wrong that that isn't happening? Or help clarify my understanding?
Thanks so much!
James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
-- James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
;; using list as parameter-type
(define-easy-handler (form-page :uri "/") () (with-html-output-to-string (out) (:form :action "/process" (:input :type "text" :name "task[]" :value "37") (:input :type "text" :name "task[]" :value "38") (:input :type "text" :name "task[]" :value "36") (:input :type "submit" :value "Process"))))
(define-easy-handler (process-page :uri "/process") ((tasks :real-name "task[]" :parameter-type 'list)) (with-html-output-to-string (out) (print tasks out)))
;; array parameter-type needs fields names to be something like task[36], task[38] ... etc, ;; not with empty square brackets like task[], so the following wont work. (define-easy-handler (process-page :uri "/process") ((tasks :real-name "task" :parameter-type 'array)) (with-html-output-to-string (out) (print tasks out)))
;; but using this will allow you to use array parameter type, and thus the above easy-handler will work
(define-easy-handler (form-page :uri "/") () (with-html-output-to-string (out) (:form :action "/process" (:input :type "text" :name "task[0]" :value "37") (:input :type "text" :name "task[1]" :value "38") (:input :type "text" :name "task[2]" :value "36") (:input :type "submit" :value "Process"))))
On Sat, Feb 9, 2013 at 11:19 PM, Jim Barrows jim.barrows@gmail.com wrote:
Fixed that, and it didn't work. I went through all three permutations (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((task :parameter-type 'list)) (task-prioritize task))
results in: [2013-02-09 12:18:40 [DEBUG]] task-prioritize NIL
[2013-02-09 12:18:40 [DEBUG]] parameters ((task[] . 37) (task[] . 38) (task[] . 36))
On Sat, Feb 9, 2013 at 11:47 AM, Ala'a Mohammad amalawi@gmail.com wrote:
the parameter name is "task[]", not "tasks" used as a default name for the 'tasks' parameter in the easy handler.
try using real-name
HiH
Ala'a
On Sat, Feb 9, 2013 at 10:42 PM, Jim Barrows jim.barrows@gmail.com wrote:
I'm a Lisp newbie trying to use the jquery ui sortable widget (http://api.jqueryui.com/sortable/) to sort a list of tasks. The plugin posts the list of tasks as:
task[]: 37 task[]: 36 task[]: 38
Which Hunchentoot sees as: [2013-02-09 11:15:34 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
However, when I use this handler: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) (tasks) (task-prioritize tasks))
I get: [2013-02-09 11:38:52 [DEBUG]] task-prioritize NIL
[2013-02-09 11:38:52 [DEBUG]] parameters ((task[] . 36) (task[] . 38) (task[] . 37))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'array)) (task-prioritize tasks)) I get: [2013-02-09 11:36:07 [DEBUG]] task-prioritize #()
[2013-02-09 11:36:07 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'list)) (task-prioritize tasks)) I get: [2013-02-09 11:37:32 [DEBUG]] task-prioritize NIL
[2013-02-09 11:37:32 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
My understanding from the documentation is that I should end up with a list of id's in the var task when is all said and done. Could someone tell me what I'm doing wrong that that isn't happening? Or help clarify my understanding?
Thanks so much!
James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
-- James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
Unfortunately,. the JQuery sortable api is the on that determines the names of the fields, and not me. Thanks for the help though! It is greatly appreciated!
On Sat, Feb 9, 2013 at 12:40 PM, Ala'a Mohammad amalawi@gmail.com wrote:
;; using list as parameter-type
(define-easy-handler (form-page :uri "/") () (with-html-output-to-string (out) (:form :action "/process" (:input :type "text" :name "task[]" :value "37") (:input :type "text" :name "task[]" :value "38") (:input :type "text" :name "task[]" :value "36") (:input :type "submit" :value "Process"))))
(define-easy-handler (process-page :uri "/process") ((tasks :real-name "task[]" :parameter-type 'list)) (with-html-output-to-string (out) (print tasks out)))
;; array parameter-type needs fields names to be something like task[36], task[38] ... etc, ;; not with empty square brackets like task[], so the following wont work. (define-easy-handler (process-page :uri "/process") ((tasks :real-name "task" :parameter-type 'array)) (with-html-output-to-string (out) (print tasks out)))
;; but using this will allow you to use array parameter type, and thus the above easy-handler will work
(define-easy-handler (form-page :uri "/") () (with-html-output-to-string (out) (:form :action "/process" (:input :type "text" :name "task[0]" :value "37") (:input :type "text" :name "task[1]" :value "38") (:input :type "text" :name "task[2]" :value "36") (:input :type "submit" :value "Process"))))
On Sat, Feb 9, 2013 at 11:19 PM, Jim Barrows jim.barrows@gmail.com wrote:
Fixed that, and it didn't work. I went through all three permutations (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((task :parameter-type 'list)) (task-prioritize task))
results in: [2013-02-09 12:18:40 [DEBUG]] task-prioritize NIL
[2013-02-09 12:18:40 [DEBUG]] parameters ((task[] . 37) (task[] . 38) (task[] . 36))
On Sat, Feb 9, 2013 at 11:47 AM, Ala'a Mohammad amalawi@gmail.com
wrote:
the parameter name is "task[]", not "tasks" used as a default name for the 'tasks' parameter in the easy handler.
try using real-name
HiH
Ala'a
On Sat, Feb 9, 2013 at 10:42 PM, Jim Barrows jim.barrows@gmail.com wrote:
I'm a Lisp newbie trying to use the jquery ui sortable widget (http://api.jqueryui.com/sortable/) to sort a list of tasks. The plugin posts the list of tasks as:
task[]: 37 task[]: 36 task[]: 38
Which Hunchentoot sees as: [2013-02-09 11:15:34 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
However, when I use this handler: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) (tasks) (task-prioritize tasks))
I get: [2013-02-09 11:38:52 [DEBUG]] task-prioritize NIL
[2013-02-09 11:38:52 [DEBUG]] parameters ((task[] . 36) (task[] . 38) (task[] . 37))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'array)) (task-prioritize tasks)) I get: [2013-02-09 11:36:07 [DEBUG]] task-prioritize #()
[2013-02-09 11:36:07 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
If I use: (define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) ((tasks :parameter-type 'list)) (task-prioritize tasks)) I get: [2013-02-09 11:37:32 [DEBUG]] task-prioritize NIL
[2013-02-09 11:37:32 [DEBUG]] parameters ((task[] . 37) (task[] . 36) (task[] . 38))
My understanding from the documentation is that I should end up with a list of id's in the var task when is all said and done. Could someone tell me what I'm doing wrong that that isn't happening? Or help clarify my understanding?
Thanks so much!
James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
-- James A Barrows
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
On Feb 9, 2013, at 21:53 , Jim Barrows jim.barrows@gmail.com wrote:
Unfortunately,. the JQuery sortable api is the on that determines the names of the fields, and not me. Thanks for the help though! It is greatly appreciated!
You may be able to use something like the following (untested):
(hunchentoot:define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) () (let ((tasks (mapcar #'cdr (remove-if-not (lambda (x) (string= (car x) "task[]")) (hunchentoot:get-parameters*))))) (task-prioritize tasks)))
If your request use "POST", you may have to replace get-parameters* with post-parameters*, or possibly to have both combined with append.
Raymond Wiker rwiker@gmail.com writes:
On Feb 9, 2013, at 21:53 , Jim Barrows jim.barrows@gmail.com wrote:
Unfortunately,. the JQuery sortable api is the on that determines the names of the fields, and not me. Thanks for the help though! It is greatly appreciated!
You may be able to use something like the following (untested):
(hunchentoot:define-easy-handler (task-prioritize-url-handler :uri *task-prioritize*) () (let ((tasks (mapcar #'cdr (remove-if-not (lambda (x) (string= (car x) "task[]")) (hunchentoot:get-parameters*))))) (task-prioritize tasks)))
If your request use "POST", you may have to replace get-parameters* with post-parameters*, or possibly to have both combined with append.
Not really relevant to the problem, just some "protips":
(remove-if-not (lambda (x) (string= (car x) "task[]")) (hunchentoot:get-parameters*)) => (remove "task[]" (hunchentoot:get-parameters*) :key #'car :test #'string/=)
But with mapcar #'cdr combined, it'd be better: (loop for (key . value) in (get-parameters*) when (string= key "task[]") collect value)