-
1. Re: Help understanding Entity component lifecycle
gavin.king Jun 19, 2006 2:39 PM (in response to rpiaggio)Just don't make it a Seam component.
You can outject any object to a Seam context variable, not just Seam components. -
2. Re: Help understanding Entity component lifecycle
rpiaggio Jun 19, 2006 2:58 PM (in response to rpiaggio)The reason why I am making it a Seam component is to specify the scope in one signle place in the code.
If I don't make it a Seam component, then I have to specify the scope in every outjection. This means that if I want to change the behavior it in the future then I will have to change n places in the code instead of just one.
Is there a way to specify the default scope of a variable that's not a Seam component? (I can do it the JSF way in faces-config.xml I guess, would that work with Seam?) -
3. Re: Help understanding Entity component lifecycle
rpiaggio Jun 20, 2006 12:16 PM (in response to rpiaggio)Let me rephrase:
Is there a way to specify a default Seam scope for variables that are not Seam components?
If not, can we turn it into a feature request? -
4. Re: Help understanding Entity component lifecycle
gavin.king Jun 20, 2006 1:49 PM (in response to rpiaggio)I suppose I could let you write @Scope on a class with no @Name. Put it in JIRA and I'll make a decision about that later. I don't love it, but maybe I can grow to like it.
-
5. Re: Help understanding Entity component lifecycle
rpiaggio Jun 20, 2006 2:17 PM (in response to rpiaggio)Thanks for considering it, Gavin.
However, I don't like it either because it doesn't fully solve the problem: in the example above, the same class would be used as a Seam component in some roles but not in others.
My suggestion: a "create" property in the @Role annotation (and in @Scope?). Defaults to "true", but we could specify ("create=false").
This would allow null values in Seam components. (I'm JIRAing this suggestion).
Maybe this conflicts heavily with what a "Seam-managed component" is supposed to be. Then the solution would be to create a new annotation specifying a role and default scope (again, the same class could have different roles even if it's not a Seam component in any of them). But wouldn't that just look too much like the @Role annotation?
(All these forum messages with "feature XX doesn't work" and "feature YY" requests may sound a bit harsh, so let me use this opportunity to express, for what it's worth, how great a job I think you guys are doing with Seam). -
6. Re: Help understanding Entity component lifecycle
liudan2005 Jun 21, 2006 5:25 AM (in response to rpiaggio)I've had similar problem and this is how I solved my problem. Don't know if it helps to solve your problem.
Basically I created another wrapper object UserService for User. When currentUser is requested, I manually check the sesssion and decides what to return. Here is some my code.
UserService.java@Name("currentUser") @Scope(SESSION) public class UserService { @Unwrap public User getUser() { return getMyCurrentUser(...); } ... }
User.java@Entity @Name("dummyUser") @Scope(SESSION) @Roles( { @Role(name = "loginUser", scope = ScopeType.EVENT), @Role(name = "newUser", scope = ScopeType.CONVERSATION) }) public class User implements Serializable { ... }