Dynamic argument list with coldfusion methods using argumentCollection

Check out the link, and learn how to use pass arguments to Coldfusion methods using the argumentCollection as your parameter. This is slick.

I was doing the following, concatenating my argument list to change with logic. I should have been using an argument struct instead of a clumsy string that was being evaluated like this:




argsColl = "";
argsColl &= "username=Almonzo,";
argsColl &= "password="LauRa123";
authorized = securityCFC.getAuth(Evaluate(argsColl));

The following was so much cooler, cut my code down, and made it so I didn’t have to figure out why the Evaluate function won’t evaluate strings with commas:)



argsColl = structNew();
argsColl.username = "Almonzo";
argsColl.password = "LauRa123";
authorized = securityCFC.getAuth(argumentCollection = argsColl);

Helpful link:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_28.html

Leave a Reply

Your email address will not be published. Required fields are marked *