![]() |
|
#1
|
|||
|
|||
|
Hi all,
I can't initialize a property with an empty string: Code:
<property name="mystringprop" value="" /> Is this a bug or are there some reasons for this? cheers, Erich |
|
#2
|
|||
|
|||
|
I don't think there is a good reason, even if there is one. What you are trying to do should definitely be allowed, although I would probably prefer to set it to String.Empty explicitly...
- Aleks Last edited by Aleks Seovic; 10-23-2006 at 11:48 AM. |
|
#3
|
|||
|
|||
|
Quote:
Writing Code:
<property name="mystringprop" value="string.Empty" /> Code:
<property name="TestData"><object type="System.String" /></property> And coming up with a PropertyRetrievingFactoryObject is imho a slight overkill for injecting an empty string... Edit: I just found an easy solution: Code:
<property name="TestData"><value /></property> Btw: I was looking at Spring.Expressions to find a way, but had no luck (they are not used in this case). But I had an idea: What about adding some "ExpressionFactoryObject" to Spring.Core? Since expressions are a real mighty tool, one could easily inject many things with less xml-verbosity. e.g. above problem could be solved with Code:
<property name="TestData"><value type="ExpressionEvaluatingFactoryObject">String.Empty</value></property> cheers, Erich Last edited by Erich Eichinger; 10-23-2006 at 12:47 PM. Reason: found solution |
|
#4
|
|||
|
|||
|
Quote:
or something like this : Code:
<property name="TestData"><eval>String.Empty</eval></property> Code:
<ItemsControl ItemsSource="{s:Eval '@TheMovieLister.GetAllMovies()'}" />
__________________
My english is as poor as my taylor is rich
|
|
#5
|
|||
|
|||
|
Hi,
I made JIRA entries for both the bug above (#SPRNET-379) and the "DI by expressions"-feature (#SPRNET-378) cheers, Erich |
|
#6
|
|||
|
|||
|
Yeah, I agree that we should be able to use expressions to set property values.
Probably the best approach would be to add expression attribute and element to the configuration schema, which could be used wherever value attribute/element is used. That way you would be able to set your empty string like this: <property name="mystringprop" expression="String.Empty" /> or this <property name="mystringprop" expression="''" /> (single quotes are used to specify an empty string expression) - Aleks Last edited by Aleks Seovic; 10-30-2006 at 06:33 PM. |
|
#7
|
|||
|
|||
|
Hi,
Added an issue in JIRA about the expression attribute/element and an IFactoryObject Implementation that returns an Expression evaluation : Code:
<object id="logger" type="ExpressionEvaluatorFactoryObject">
<property name="expression" value="IMpsLogMgr.getLogger("com.foo.bar")"/>
</object>
Oups, just remember that Erich already added one issue about this... [/Edit] Bruno
__________________
My english is as poor as my taylor is rich
Last edited by Bruno Baia; 11-05-2006 at 11:25 PM. |
|
#8
|
|||
|
|||
|
I see that you two started to create duplicate issues for this and decided that it should be fixed before there are 10 more related issues in JIRA
![]() This feature has been implemented and tested and it's in the CVS. It should be in the nightly build as soon as CI server issues are resolved. - Aleks |
|
#9
|
|||
|
|||
|
Quote:
![]() Bruno
__________________
My english is as poor as my taylor is rich
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|