-
1. Re: Factory with @Out in Weld
nickarls Mar 3, 2010 9:47 AM (in response to umajeric)Show the full code of the beans
-
2. Re: Factory with @Out in Weld
umajeric Mar 3, 2010 9:58 AM (in response to umajeric)I found out that my problem was not in the code but in icefaces. I had some other issue.
This solution with the @Producer annotation is it correct, or is there some other one?Uros
-
3. Re: Factory with @Out in Weld
nickarls Mar 3, 2010 10:03 AM (in response to umajeric)Yes, a producer method (or even field) is the new @Out (sort of)
-
4. Re: Factory with @Out in Weld
umajeric Mar 3, 2010 10:09 AM (in response to umajeric)And how would this solution look like on field?
-
5. Re: Factory with @Out in Weld
nickarls Mar 3, 2010 10:11 AM (in response to umajeric)@Produces @Named @SessionScoped private List<Object> myList;
-
6. Re: Factory with @Out in Weld
umajeric Mar 3, 2010 10:14 AM (in response to umajeric)yes, but where to write then a
factory
method, that actually initialises the list? -
7. Re: Factory with @Out in Weld
umajeric Apr 3, 2010 12:06 PM (in response to umajeric)Hi,
I found out the solution. it would look like this:@SessionScoped public class MyListProducer { @Produces @Named private List<Object> myList; @Inject public void init() { myList = new ArrayList(); } }
thanks.
-
8. Re: Factory with @Out in Weld
pmuir Apr 12, 2010 12:23 PM (in response to umajeric)
Uros Majeric wrote on Apr 03, 2010 12:06:@SessionScoped public class MyListProducer { @Produces @Named private List<Object> myList; @Inject public void init() { myList = new ArrayList(); } }
thanks.Whilst this will work, I would not recommend it. The reason we have both producer methods and fields is to allow you to do initialization work in a method if needed...
-
9. Re: Factory with @Out in Weld
umajeric Apr 13, 2010 7:57 AM (in response to umajeric)
Whilst this will work, I would not recommend it. The reason we have both producer methods and fields is to allow you to do initialization work in a method if needed...why not recommended? this is exactly what I need.
-
10. Re: Factory with @Out in Weld
nickarls Apr 13, 2010 8:13 AM (in response to umajeric)Generally it's perhaps more readable to have the entire operation encapsulated inside a producer method instead of having the reader look around for the initialization part.