【问题标题】:Element componentValidation is not defided in variable元素组件验证未在变量中定义
【发布时间】:2017-06-19 12:30:03
【问题描述】:

我的一个组件中有一个方法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>

我想从另一个组件调用上述方法。我试着像这样从common.cfc 调用它

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 ) />

但是我得到一个错误,比如 Elementcomponent 没有在 componentValidation.cfc 的变量中定义(它已经在我的 init() 函数中定义)。有什么想法吗?

【问题讨论】:

  • 如有疑问,请查看您的数据。如果您有一个名为 componentValidation.cfc 的变量,请将其转储并查看其中的内容。
  • @Dan Bracuk 有 variablevalidationtypes 添加它提供正确的验证类型

标签: coldfusion coldfusion-8 coldfusion-11


【解决方案1】:

这可能是个错误:

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

不应该是:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 2021-12-22
    • 1970-01-01
    相关资源
    最近更新 更多