[hunchentoot-devel] Need some help figuring out what I'm doing wrong trying to get post parameters passed properly

Stas Boukarev stassats at gmail.com
Mon Feb 11 14:12:30 UTC 2013


Raymond Wiker <rwiker at gmail.com> writes:

> On Feb 9, 2013, at 21:53 , Jim Barrows <jim.barrows at 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)


-- 
With best regards, Stas.




More information about the Tbnl-devel mailing list