This content has been marked as final.
Show 3 replies
-
1. Re: promoting beans to higher scopes
sebek64 Mar 15, 2010 1:52 PM (in response to sebek64)It seems that the code above is invalid. I found this solution. The data class is not a seam component itself. Instead, there is a component in request scope that only instantiates the data class and holds a reference to it. When the component is destroyed, it's still valid to hold reference to the data class in a collection.
@Name("conv") @Scope(CONVERSATION) class Conv { List<CustomEntry> listOfEntries; public void addEntry(EntryRef e) { listOfEntries.add(e.getRef()); } }
@Name("entryRef") @Scope(EVENT) class EntryRef { private CustomEntry ref = new CustomEntry(); public CustomEntry getRef() { return ref; } }
class CustomEntry { // some data supplied by user in a JSF form }
-
2. Re: promoting beans to higher scopes
sebek64 Mar 15, 2010 2:03 PM (in response to sebek64)And when I think about it, the same result could be achieved using @Factory:
@Name("conv") @Scope(CONVERSATION) class Conv { List<CustomEntry> listOfEntries; public void addEntry(CustomEntry e) { listOfEntries.add(e); } @Factory public void createEntry() { return new CustomEntry e; } }
-
3. Re: promoting beans to higher scopes
sebek64 Mar 15, 2010 2:05 PM (in response to sebek64)oops, there should be @Factory("entry",scope=EVENT).