Mach-II/Mach-II-Framework — Issue #70: New idea - Event getArgAsArray() method
Author: mpwoodward
Created: 2012-03-01 19:29:27+00:00
State: open
Labels: enhancement

(Moved from http://trac.mach-ii.com/machii/ticket/328)

I've been doing some reading up on Django. All POST (form) and GET (url) parameters are put into a queryDict object in their httpRequest object.

CFML engines take multiple parameters (?a=1&a=2&a=3) and puts them in a list for you (url.a=1,2,3). Django however only gives you the last item in the parameter's value. Side step: Django uses lists which is akin to CFML arrays. So if did queryDict.getItem('a') in Django with our example, I would get a value of 3 because it's the last item. If I wanted to get the whole list (think CFML array), I would have to call queryDict.getList('a'). So you still have to know that parameter you want to work with could post multiple value in Django (no magic here).

I'm not advocating to change the Event object to work like this because CFML has string lists (even though they are just represented as strings in the grand schema). I was thinking that I when I'm dealing with multiple parameters in CFML I always have to do this:

`var a = ListToArray(arguments.event.getArg('a'));`

Wouldn't it be nice if you could just do this when working with multiples:

`var a = arguments.event.getArgAsArray('a');`

I could be totally hate this tomorrow, but it was a new idea and I thought I would log it. It's ok to point fingers and laugh if you want. ;-)

Changed 3 years ago by Jorge Loyo

I can see a few instances in which this could be used in my application. However, if you add an additional optional parameter to specify the delimiter of the list then, maybe, you would just be adding more code to the framework that would simply translate to a "ListToArray?()".

If added, I would probably use it, but since it would not replace a lot of code for a single line (i.e. CopyToScope?) I wouldn't see this as a major super duper addition.

comment:2 Changed 3 years ago by kurtwiersma

I don't find I have to convert lists into array's that much but I can see how the mutli parameter CF issue makes this handy.

comment:3 Changed 2 years ago by peterfarrell

Version changed from 1.9.0 - Framework to Uncategorized - Framework
Milestone changed from Mach-II 1.9.0 alpha to Uncategorized