Changeset 1594
- Timestamp:
- 06/13/2009 09:47:14 AM (9 months ago)
- Location:
- framework/1-8-0/trunk
- Files:
-
- 2 modified
-
framework/BaseComponent.cfc (modified) (1 diff)
-
util/ExpressionEvaluator.cfc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
framework/1-8-0/trunk/framework/BaseComponent.cfc
r1581 r1594 373 373 hint="The current value of the parameter." /> 374 374 375 <cfset var propertyName = "" />375 <cfset var expressionEvaluator = getAppManager().getExpressionEvaluator()> 376 376 <cfset var value = arguments.parameterValue /> 377 <cfset var scope = "" /> 378 <cfset var event = "" /> 377 379 378 380 <!--- 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() /> 384 402 <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() /> 387 404 </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> 388 415 </cfif> 389 416 -
framework/1-8-0/trunk/util/ExpressionEvaluator.cfc
r1562 r1594 41 41 PROPERTIES 42 42 ---> 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" /> 45 45 46 46 <!--- … … 102 102 <cfif len(body)> 103 103 <cfset expDetails.operand = listGetAt(body, 1, " ") /> 104 <cfif NOT listFindNoCase(variables. operandList, expDetails.operand)>104 <cfif NOT listFindNoCase(variables.OPERAND_LIST, expDetails.operand)> 105 105 <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#)" /> 107 107 </cfif> 108 108 <cfset body = listDeleteAt(body, 1, " ") /> … … 131 131 </cffunction> 132 132 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 ---> 133 155 <cffunction name="parseOutParam" access="private" returntype="struct" output="false"> 134 156 <cfargument name="body" type="string" required="true" /> … … 235 257 </cffunction> 236 258 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 248 259 <!--- 249 260 PROTECTED FUNCTIONS
