-
1. Re: In(value="selectedCountry",create=true) private Country editedCountry;
nickarls Feb 25, 2008 9:36 AM (in response to blabno)There is usually a motivation for the design choices but at first glance one would think that create=true would guarantee creation. How does auto-create react to your case?
-
2. Re: In(value="selectedCountry",create=true) private Country editedCountry;
blabno Feb 25, 2008 10:57 AM (in response to blabno)This is so bad !
I've read the code responsible for injection. It will first search context for variable with name matchingvalue
or member's name ifvalue
is not specified. If nothing is find then it will try to find component with name matching, as above,value
or member's name. (all is done in org/jboss/seam/Component.java)This is a serious limitation that allows us to have only one member created during injection.
I would like to have something like this :
class Sth { @In(value="notAComponentNameAtAll1",create=true) Country notAComponentName1; @In(value="notAComponentNameAtAll2",create=true) Country notAComponentName2; }
So there should be an additional attribute in @In annotation like
component
.What do you think Seam developers ? I could write a patch ?
-
3. Re: In(value="selectedCountry",create=true) private Country editedCountry;
pmuir Feb 25, 2008 10:24 PM (in response to blabno)Use @Role and read the reference manual.
-
4. Re: In(value="selectedCountry",create=true) private Country editedCountry;
blabno Feb 26, 2008 10:03 AM (in response to blabno)I've read reference and 2 other books on seam. It is poorly explained how @In annotation works. At least in examples. I know that at the end in reference in Annotations part you wrote a sentence :
create — specifies that Seam should instantiate the component with the same name as the context variable if the context variable is undefined (null) in all contexts. Default to false.Just know, that it is the only one sentence about it in all reference.
I think, that my solution, with extending @In annotation is more flexible than adding @Role to a component.
But, anyway, thank you very much for response.
-
5. Re: In(value="selectedCountry",create=true) private Country editedCountry;
blabno Feb 26, 2008 11:13 AM (in response to blabno)Hey guys, I've extended @In annotation as proposed, and recompiled seam on my machine, and everything rocks.
--- /mnt/sda5/bernard/original/In.java 2008-02-26 10:12:59.000000000 +0000 +++ annotations/In.java 2008-02-26 11:04:49.000000000 +0000 @@ -49,4 +49,13 @@ * More efficient as it avoids scanning all contexts */ ScopeType scope() default ScopeType.UNSPECIFIED; + + /** + * Name of component to create if create is set to + * true, and there is no context variable for neither + * value nor member's name, and they both are different + * from component's name. + * @author Bernard Labno + */ + String component() default ""; }
--- /mnt/sda5/bernard/original/Component.java 2008-02-26 10:12:53.000000000 +0000 +++ Component.java 2008-02-26 10:38:00.000000000 +0000 @@ -2163,6 +2163,11 @@ } } + if( result==null && in.create() && in.component()!=null && !in.component().equals("") ) + { + result = getInstance(in.component(),true,null); + } + if ( result==null && enforceRequired && in.required() ) { throw new RequiredException(