On Fri, Aug 22, 2008 at 11:11 PM, Lisa Lee <[EMAIL PROTECTED]> wrote:
> I used cfajaxproxy to create a JavaScript method, like so:
> <cfajaxproxy cfc=account.InternalAccountManagement"
> jsclassname="accountManager">
>
> Then, within a <script> block, I have the following:
> var am = new accountManager();
> am.setCallbackHandler(showUpdate);
> am.setErrorHandler(myErrorHandler);
> am.updatePerson(1,"Doe","John");
>
> My InternalAccountManagement.cfc has a function named, of course,
> updatePerson, and it takes three arguments: personID, lastName, and
> firstName (declared in that order in the method). What I'd really like to
> do in my JavaScript block above is to take advantage of ColdFusion's
> argumentCollection parameter, and pass 1, "Doe," and "John" within one
> argumentCollection, rather than passing them as three separate values in the
> am.updatePerson call. Is this possible?
>
well, you won't be able to use argumentCollection, because that's for cf
variables, and what you're dealing with is JS variables. the closest that
i've been able to come is to pass the data as a JSON object, and have the
CFC method expect a single argument, rather than 3. I originally had all 3
cfarguments explicitly stated, but the method apparently doesn't
'deconstruct' the argument. it saw the JSON object as the first argument
(personID), and the other two (lastName and firstName) were null.
if you're ok with the method accepting a single argument, something like
this should work:
your .cfm file:
<cfajaxproxy cfc="account.InternalAccountManagement"
jsclassname="accountManager">
<script type="text/javascript">
var am = new accountManager();
var person = { "id":1, "lastName":"Doe", "firstName":"John" };
var myResponse = am.updatePerson(person);
document.write(myResponse);
</script>
the CFC method would look like this:
<cffunction name="updatePerson" access="remote" output="false"
returnFormat="JSON">
<cfargument name="person" />
<!--- returning this as a 'for example' --->
<cfreturn arguments.person.firstName />
</cffunction>
--
A byte walks into a bar and orders a pint. Bartender asks him "What's
wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I thought
you looked a bit off."
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311461
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4