-
1. Re: Web Beans Collections Lists Maps Sets
pmuir Oct 16, 2009 1:51 AM (in response to bbviana)I don't really understand what you are asking. Try to be more concrete, less abstract.
Given that the only way you interact with scopes in CDI is via beans, no, you can't put a
collection property
into the session.If you are asking how you write a producer method which will provide a bean to inject into your field:
@Produces List<Date> getDates() { return new ArrayList<Date>(); } @Inject List<Date> dates;
-
2. Re: Web Beans Collections Lists Maps Sets
bbviana Oct 16, 2009 2:55 PM (in response to bbviana)Collections arent't web beans. I got it.
So, I shouldn't work with a collection inside a scope, right? -
3. Re: Web Beans Collections Lists Maps Sets
pmuir Oct 16, 2009 6:24 PM (in response to bbviana)Well you could certainly use a collection as a bean - as I showed above :-)
-
4. Re: Web Beans Collections Lists Maps Sets
gavin.king Oct 18, 2009 3:30 PM (in response to bbviana)You can't write @Inject List<Something> unless you have defined a bean which implements List<Something> and put it in a bean deployment archive. This is the case for any interface, nothing special about collections here. Lots of classes implement List, there's no way we can assume it is an ArrayList.
Nor can you just write @Inject ArrayList<Something>, since the class ArrayList is not in a bean deployment archive - and anyway, I'm not quite sure what the value of injecting an empty ArrayList would be.
However, if all you are trying to do is just inject a new array list with no members, you can write:
@Inject @New(ArrayList.class) List<Something>
However this does not yet work in the current release of Weld. Pete is working on it.