Element componentValidation is not defided in variable

42 Views Asked by At

There's a method in one of my components componentValitation.cfc:

<cffunction name="getValidationTypeRegExpByID" access="public" 
      returntype="string" output="false">

    <cfargument name="componentValidationTypeID" type="numeric" required="true">
    <cfscript>
        if (structKeyExists(variables.componentValidationTypes, arguments.componentValidationTypeID))
        {
            return variables.componentValidationTypes[arguments.componentValidationTypeID].RegExp;
        }
        return '';
    </cfscript>
</cffunction>

I want to call the above mentioned method from another component. I tried calling it from common.cfc like this

var advertisement = getComponentValidation('component','sys.jo.core.fe.componentValidation');
<cfset testttt = advertisement.getValidationTypeRegExpByID(componentValidationTypeID) />
<cfset errorMessage = "#componentShortLabel# #Lib.showCaption('message_Decimal2dpValidation', UserIdentity)#" />
<cfset arguments.Message.addValidationError( keyName=QuestionID,  errorMessage=errorMessage, componentKey=ComponentID, componentErrorMessage=errorMessage, tupleIndex=arguments.tupleIndex, QuestionDisplayNumber=errorDisplaySequenceNumber ) />

But I'm getting an error like Elementcomponent is not defined in variable in componentValidation.cfc (which was already defined in my init() function). Any ideas?

1

There are 1 best solutions below

0
BKBK On

This is probably a mistake:

var advertisement = getComponentValidation('component','sys.jo.core.fe.componentValidation');

Shouldn't it be:

var advertisement = createobject('component','sys.jo.core.fe.componentValidation');