Changeset 1594

Show
Ignore:
Timestamp:
06/13/2009 09:47:14 AM (9 months ago)
Author:
peterfarrell
Message:

fixes[t:306]

Location:
framework/1-8-0/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • framework/1-8-0/trunk/framework/BaseComponent.cfc

    r1581 r1594  
    373373                        hint="The current value of the parameter." /> 
    374374                 
    375                 <cfset var propertyName = "" /> 
     375                <cfset var expressionEvaluator = getAppManager().getExpressionEvaluator()> 
    376376                <cfset var value =  arguments.parameterValue /> 
     377                <cfset var scope = "" /> 
     378                <cfset var event = "" /> 
    377379                 
    378380                <!--- Can only bind simple parameter values ---> 
    379                 <cfif IsSimpleValue(arguments.parameterValue) AND REFindNoCase("\${(.)*?}", arguments.parameterValue)> 
    380                         <cfset propertyName = Mid(arguments.parameterValue, 3, Len(arguments.parameterValue) -3) /> 
    381                         <cfif getPropertyManager().isPropertyDefined(propertyName)  
    382                                 OR (IsObject(getAppManager().getParent()) AND getAppManager().getParent().getPropertyManager().isPropertyDefined(propertyName))> 
    383                                 <cfset value = getProperty(propertyName) /> 
     381                <cfif IsSimpleValue(arguments.parameterValue)  
     382                        AND expressionEvaluator.isExpression(arguments.parameterValue)> 
     383                         
     384                        <!--- 
     385                                For BC with bindable property parameters, a scope name was not "required"  
     386                                (during framework loading) and defaults to "properties", however it is best  
     387                                practice to provide a scope 
     388                        ---> 
     389                        <cfif getAppManager().isLoading()> 
     390                                <!--- Disallow event scope during framework load ---> 
     391                                <cfif value.toLowerCase().startsWith("${event.")> 
     392                                        <cfthrow type="MachII.framework.BindToParameterInvalidScope"  
     393                                                message="Cannot bind to a parameter named '#arguments.parameterName#' for '#getComponentNameForLogging()#' because the 'event.' scope is not available for use during on framework load." /> 
     394                                 
     395                                <!--- Add in properties scope if missing ---> 
     396                                <cfelseif NOT value.toLowerCase().startsWith("${properties.")> 
     397                                        <cfset value = Insert("properties.", value, 2) /> 
     398                                </cfif> 
     399                                 
     400                                <!--- Create a dummy event object to pass in ---> 
     401                                <cfset event = CreateObject("component", "MachII.framework.Event").init() /> 
    384402                        <cfelse> 
    385                                 <cfthrow type="MachII.framework.ProperyNotDefinedToBindToParameter"  
    386                                         message="The required property is not defined to bind to a parameter named '#arguments.parameterName#'." /> 
     403                                <cfset event = getAppManager().getRequestManager().getRequestHandler().getEventContext().getCurrentEvent() /> 
    387404                        </cfif> 
     405                         
     406                        <cftry> 
     407                                <cfset value = expressionEvaluator.evaluateExpression(value, event, getPropertyManager()) /> 
     408                                 
     409                                <cfcatch type="any"> 
     410                                        <cfthrow type="MachII.framework.BindToParameterException"  
     411                                                message="Error trying bind to a parameter named '#arguments.parameterName#' for '#getComponentNameForLogging()#'." 
     412                                                detail="Please check your expression for errors." /> 
     413                                </cfcatch> 
     414                        </cftry> 
    388415                </cfif> 
    389416                 
  • framework/1-8-0/trunk/util/ExpressionEvaluator.cfc

    r1562 r1594  
    4141        PROPERTIES 
    4242        ---> 
    43         <cfset variables.operandList = "eq,neq,gt,gte,lt,lte" /> 
    44         <cfset variables.parsedExpressions = StructNew() /> 
     43        <cfset variables.OPERAND_LIST = "eq,neq,gt,gte,lt,lte" /> 
     44        <cfset variables.SCOPE_LIST = "properties,event" /> 
    4545         
    4646        <!--- 
     
    102102                        <cfif len(body)> 
    103103                                <cfset expDetails.operand = listGetAt(body, 1, " ") /> 
    104                                 <cfif NOT listFindNoCase(variables.operandList, expDetails.operand)> 
     104                                <cfif NOT listFindNoCase(variables.OPERAND_LIST, expDetails.operand)> 
    105105                                        <cfthrow type="MachII.util.InvalidExpression"  
    106                                                 message="The operand '#operand#' from the expression '#arguments.expressionBody#' is not one of the following supported operands. (#variables.operandList#)" /> 
     106                                                message="The operand '#operand#' from the expression '#arguments.expressionBody#' is not one of the following supported operands. (#variables.OPERAND_LIST#)" /> 
    107107                                </cfif> 
    108108                                <cfset body = listDeleteAt(body, 1, " ") /> 
     
    131131        </cffunction> 
    132132         
     133        <!--- 
     134        PUBLIC FUNCTIONS - UTIL 
     135        ---> 
     136        <cffunction name="isExpression" access="public" returntype="boolean" output="false" 
     137                hint="Checks if passed argument is a valid expression."> 
     138                <cfargument name="expression" type="any" required="true"  
     139                        hint="This argument should be a string otherwise it this method will return false." /> 
     140                <cfif isSimpleValue(arguments.expression)> 
     141                        <cfreturn REFindNoCase("\${(.)*?}", arguments.expression) /> 
     142                <cfelse> 
     143                        <cfreturn false /> 
     144                </cfif> 
     145        </cffunction> 
     146         
     147        <cffunction name="getScopeList" access="public" returntype="string" output="false" 
     148                hint="Gets a list of scopes."> 
     149                <cfreturn variables.SCOPE_LIST /> 
     150        </cffunction> 
     151         
     152        <!--- 
     153        PROTECTED FUNCTIONS 
     154        ---> 
    133155        <cffunction name="parseOutParam" access="private" returntype="struct" output="false"> 
    134156                <cfargument name="body" type="string" required="true" /> 
     
    235257        </cffunction> 
    236258         
    237         <cffunction name="isExpression" access="public" returntype="boolean" output="false" 
    238                 hint="Checks if passed argument is a valid expression."> 
    239                 <cfargument name="expression" type="any" required="true"  
    240                         hint="This argument should be a string otherwise it this method will return false." /> 
    241                 <cfif isSimpleValue(arguments.expression)> 
    242                         <cfreturn REFindNoCase("\${(.)*?}", arguments.expression) /> 
    243                 <cfelse> 
    244                         <cfreturn false /> 
    245                 </cfif> 
    246         </cffunction> 
    247          
    248259        <!--- 
    249260        PROTECTED FUNCTIONS