rhinds
rhinds

Reputation: 10043

Optional arguments - argument passed is not an integer

I'm sure this must be a simple one, but no amount of tweaking seems to work (I'm hoping I haven't misunderstood the fundamentals here!).

I have defined a function in a CFC as follows:

public void function createWidget(  
        required any event
      , required String widgetType
      , String elementId=""
      , integer refreshRate="0"
      , required integer rowNumber
      , required integer colNumber
      , required integer width
      , required integer height
      , String title=""
      , String bgColour="orange" ){

As you can see, there are some required arguments, and some that are not required that I have provided a default value for (e.g. integer refreshRate="0" ).

Now I am calling this function using named arguments, trying to take advantage of the optional arguments, e.g:

createWidget( event:event
               , widgetType:'blank'
               , rowNumber:1
               , colNumber:1
               , width:2
               , height:1  
               , title:'Empty Widget' )

So I have not provided any value for refreshRate in this case, but I get the error:

The REFRESHRATE argument passed to the createWidget function is not of type integer.

I have also tried updating the default value for refreshRate to remove the quotation marks (integer refreshRate=0) but still the exact same problem.

Can anyone spot what I am doing wrong?


UPDATE
I have also tried actually passing in the variable refreshRate (adding refreshRate:0 to the function call) and I still get the same error!

Upvotes: 1

Views: 969

Answers (1)

rhinds
rhinds

Reputation: 10043

Ok, apparently switching the arguments to type "numeric" fixes this - not sure why Integer isn't accepted? It's a legit CF type right?

Upvotes: 3

Related Questions