[jira] Commented: (VELOCITY-186) #set does not allow to assign nulls---cannot it be changed?
[ http://issues.apache.org/jira/browse/VELOCITY-186?page=comments#action_12329890 ] Will Glass-Husain commented on VELOCITY-186: Thanks, Nathan. Ok - I agree, we need a configuration option for compatibility. We have previously adapted #foreach to work with items in a list that are null (in 1.5-dev). That's one of the reasons I'd like to make #set work with null as well. #set does not allow to assign nulls---cannot it be changed? --- Key: VELOCITY-186 URL: http://issues.apache.org/jira/browse/VELOCITY-186 Project: Velocity Type: Improvement Components: Source Versions: 1.3.1 Environment: Operating System: All Platform: All Reporter: Tomislaw Kitynski Assignee: Velocity-Dev List Priority: Minor Fix For: 1.5 Attachments: patchfile.txt Currently #set does not change $ref if the value is null. To quote manual: If the RHS evaluates to null, it is not assigned to the LHS. It has some advantages, but well, it has also disadvantages. In my concrete case, I have #foreach loop, where I list some items. Unfortunatley, the listing (I mean the output) heavily depends on values of some fields. Considering I have #foreach $item in $items I have to call $item.foo or $item.bar every time I need to check if the value is set or not. Instead I'd prefer to #set ($foo = $item.foo) a.s.o. and to use just $foo in further processing instead of calling $item getFoo() method all the time--- it's not only about ease of writting, it's also about the time it takes to invoke that method, plus the time of what this metod really does (it's not always just simple return this.foo statement). Of course I would not like to break the compatibility of the #set behaviour, but I wonder if would be there a way to actually add the possibility to set some $ref to null, what would casue #if ($ref) to evaluate as false. Currently, using #set causes, that if we step on $item.foo that returns null, we have $ref set to the value of a previous $item. The workaround is to use $item.foo everywhere, but it's not very comfortable. Can it be done something about that? Maybe on option in velocity.properties enabling of returning nulls or new operator (instead of '=') to assign null values (like ':=' for example). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[jira] Commented: (VELOCITY-186) #set does not allow to assign nulls---cannot it be changed?
[ http://issues.apache.org/jira/browse/VELOCITY-186?page=comments#action_12329765 ] Will Glass-Husain commented on VELOCITY-186: I've been thinking about this. Why is this patch not backwards compatible? All that happens is that statements which previously generated errors now do not. Old templates will still work. New templates can take advantage of this. Am I right? If so, we can do this for 1.5 with no configuration option. #set does not allow to assign nulls---cannot it be changed? --- Key: VELOCITY-186 URL: http://issues.apache.org/jira/browse/VELOCITY-186 Project: Velocity Type: Improvement Components: Source Versions: 1.3.1 Environment: Operating System: All Platform: All Reporter: Tomislaw Kitynski Assignee: Velocity-Dev List Priority: Minor Fix For: 1.5 Attachments: patchfile.txt Currently #set does not change $ref if the value is null. To quote manual: If the RHS evaluates to null, it is not assigned to the LHS. It has some advantages, but well, it has also disadvantages. In my concrete case, I have #foreach loop, where I list some items. Unfortunatley, the listing (I mean the output) heavily depends on values of some fields. Considering I have #foreach $item in $items I have to call $item.foo or $item.bar every time I need to check if the value is set or not. Instead I'd prefer to #set ($foo = $item.foo) a.s.o. and to use just $foo in further processing instead of calling $item getFoo() method all the time--- it's not only about ease of writting, it's also about the time it takes to invoke that method, plus the time of what this metod really does (it's not always just simple return this.foo statement). Of course I would not like to break the compatibility of the #set behaviour, but I wonder if would be there a way to actually add the possibility to set some $ref to null, what would casue #if ($ref) to evaluate as false. Currently, using #set causes, that if we step on $item.foo that returns null, we have $ref set to the value of a previous $item. The workaround is to use $item.foo everywhere, but it's not very comfortable. Can it be done something about that? Maybe on option in velocity.properties enabling of returning nulls or new operator (instead of '=') to assign null values (like ':=' for example). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]