Skip to main content
October 24, 2008
Question

Problem with CFARGUMENT type of Numeric.

  • October 24, 2008
  • 4 replies
  • 2109 views
Okay, I know this is erroring because the empty string passed to my CFARGUMENT tag isn't strictly numeric...it's empty. BUT, is there no way to have a numeric type CFARGUMENT tag empty?

I have a form which users can make settings etc for various image editing parameters. One of these fields is a HEIGHT field where the user can choose to enter a height for the image where the function will then scale it. HOWEVER, sometimes, we don't want to enter a value at all because we might not want to scale it. For this reason, the CFC errors because the value passed is empty and thus not numeric. BUT, I am unable to supply a default="0" to stop it because otherwise the image function will squash it right down to this height.

Any ideas??

I could solve it by putting type="string"...but this, seems nasty to me.

The invoke:
<cfinvokeargument name="imageHeight" value="#form.imageHeight#" />

The receiving argument in the CFC
<cfargument name="imageHeight" type="numeric" default="" required="no" />

The error message:
The IMAGEHEIGHT argument passed to the uploadImage function is not of type numeric.

Any help would be greatly appreciated.

Many thanks,
Mikey.
    This topic has been closed for replies.

    4 replies

    Inspiring
    October 24, 2008
    quote:

    Originally posted by: Kapitaine
    Okay, I know this is erroring because the empty string passed to my CFARGUMENT tag isn't strictly numeric...it's empty. BUT, is there no way to have a numeric type CFARGUMENT tag empty?

    I have a form which users can make settings etc for various image editing parameters. One of these fields is a HEIGHT field where the user can choose to enter a height for the image where the function will then scale it. HOWEVER, sometimes, we don't want to enter a value at all because we might not want to scale it. For this reason, the CFC errors because the value passed is empty and thus not numeric. BUT, I am unable to supply a default="0" to stop it because otherwise the image function will squash it right down to this height.

    Any ideas??

    I could solve it by putting type="string"...but this, seems nasty to me.

    The invoke:
    <cfinvokeargument name="imageHeight" value="#form.imageHeight#" />

    The receiving argument in the CFC
    <cfargument name="imageHeight" type="numeric" default="" required="no" />

    The error message:
    The IMAGEHEIGHT argument passed to the uploadImage function is not of type numeric.

    Any help would be greatly appreciated.

    Many thanks,
    Mikey.

    What is the value of form.imageheight?
    October 24, 2008
    Hmmm, it seems okay if I do this first.

    <cfinvokeargument name="imageHeight" value="#val(form.imageHeight)#" />

    Uisng the VAL() function seems to work okay.

    Thanks,
    Mikey.
    October 24, 2008
    Hi,

    Thanks for your help. I tried your method ...i.e if it is 0 then we can assume the user wont want to actually scale it to zero and we can therefore skip this part of image processing out.

    However, the CFARGUMENT tag still errors on this even if I set a default value of 0.

    <cfargument name="imageHeight" type="numeric" default="0" required="no" />

    "The IMAGEHEIGHT argument passed to the uploadImage function is not of type numeric."

    What in the hell is going on? This is just strange.

    Thanks,
    Mikey.
    Inspiring
    October 24, 2008
    quote:

    Originally posted by: Kapitaine
    However, the CFARGUMENT tag still errors on this even if I set a default value of 0.

    <cfargument name="imageHeight" type="numeric" default="0" required="no" />
    "The IMAGEHEIGHT argument passed to the uploadImage function is not of type numeric."
    What in the hell is going on? This is just strange.
    ...
    <cfinvokeargument name="imageHeight" value="#val(form.imageHeight)#" />



    That is not how "default" works. The "Default" kicks in only when you do _not_ pass in a value for the argument. You _are_ supplying a value. It does not matter if is an empty string. It is still a value. So whatever value is passed in must be type="numeric". #val(form.imageHeight)# probably works because the val() of an empty string is "0", which is obviously numeric.


    Inspiring
    October 24, 2008
    Kapitaine wrote:
    > I am unable to supply a default="0"

    Why? Either way it sounds like "some" condition determines whether the image is scaled. That condition could be:

    <cfargument name="height" default="0">
    <cfif arguments.height gt 0>
    scale the image
    </cfif>

    It could also be the presence of the argument

    <cfargument name="imageHeight" type="numeric" default="" required="no" />
    <cfif structKeyExists(arguments, "imageHeight")>
    scale the image
    </cfif>


    > the user can choose to enter a height for the image where the function will then scale it.
    > sometimes, we don't want to enter a value at all because we might not want to scale it.

    I assume the function is doing something else as well.. ?