-
1. Re: How can I do this with Seam?
monkeyden Jun 11, 2008 7:37 PM (in response to samdoyle)I'm confused...is it global (application) or session scoped? Also not sure what you mean by
across all pages
.Based on my understanding of the question, the answer is yes. You would create a seam component as such:
@Name("global") @Scope(ScoreType.SESSION) //or ScoreType.APPLICATION @Startup //creates one when session/application context is created public class GlobalThingy{ ... }
-
2. Re: How can I do this with Seam?
monkeyden Jun 11, 2008 7:42 PM (in response to samdoyle)Doh!
ScoreType = ScopeType
-
3. Re: How can I do this with Seam?
samdoyle Jun 11, 2008 7:46 PM (in response to samdoyle)Hello and thanks no I meant session scoped. And I did try to apply the @Startup to the component as you mentioned but then I try to inject it I get the @In attribute requires non-null value: exception
So as you mentioned this is what I have:
@Stateful @Startup @Scope( ScopeType.SESSION ) @Name( "global" )
Then in another class I have for example using the name Global
@In( required = true ) Global global;
I had thought the @Startup would provide what I needed but it doesn't appear to do so.
-
4. Re: How can I do this with Seam?
monkeyden Jun 11, 2008 8:08 PM (in response to samdoyle)I would guess that @Startup would imply @AutoCreate but, based on what I'm hearing from you, I guess not. Try adding @AutoCreate at the class level.
@Name("global") @AutoCreate @Scope(ScoreType.SESSION) //or ScoreType.APPLICATION @Startup //creates one when session/application context is created public class GlobalThingy{ ... }
-
5. Re: How can I do this with Seam?
samdoyle Jun 11, 2008 8:32 PM (in response to samdoyle)Ok there is something really strange happening here or there is something about Seam I'm missing.
I have annotated the setter method with @In
Even with the injected value being required I will still hit a case where a null value is passed in. The first injection is fine but then the second time it is null. So as an example using Global:
@In
public void setGlobal( Global global)
{
global.setListener( this );
} -
6. Re: How can I do this with Seam?
samdoyle Jun 11, 2008 8:46 PM (in response to samdoyle)Alright so I was able to accomplish what I was trying to do thanks for your help. However, I must explicitly check for a null value passed into the @In setter even though it is required. Is this a bug?
-
7. Re: How can I do this with Seam?
monkeyden Jun 11, 2008 9:39 PM (in response to samdoyle)Post the code for both components
-
8. Re: How can I do this with Seam?
samdoyle Jun 11, 2008 9:46 PM (in response to samdoyle)Thanks, unfortunately I can't post the entire code I would have to refactor all the names :). However, I guess the basic question is if you have a setter method for an injected value annotated with @In shouldn't you always be guaranteed it isn't null and if it is you should get an exception? In my case there is a null value passedin.