bau
bau

Reputation: 21

Strategy for passing in optional arguments to remotely accessed CFC's

I know that in ColdFusion, making the access level of a function remote means that all arguments are required. How do I correctly deal with optional arguments? Often we are getting requests sent to these functions with:

?method=doSomething&requiredArg="something"&optionalArg1=&optionalArg2= 

Is the only way to deal with this making the type of the argument in the function "any" or "string" and doing type checking in the code? I'm considering building an master "remoteApiCFC" that does this with a function and running it on every remote function to get a local.arguments struct. Is there a better way?

Upvotes: 0

Views: 98

Answers (1)

Redtopia
Redtopia

Reputation: 5247

This is how you define optional arguments for a method:

remote string function foo (
    required string bar,
    string option1="optional") {

    return(bar & option1);
}

Upvotes: 1

Related Questions