-
1. Re: how to change the value of session scoped variable
davidsonrik12 Jul 27, 2012 12:15 PM (in response to johnnyren)I am trying to understand how cdi weld works as well and being a seam 2 user i am trying to figure out how this would work in seam 3. i.e., when a variable in context needs to be updated. Also is there an equivalent of this
Contexts.getConversationContext.set("xyz", someObject);
?
say when i need to manually insert into the context
-
2. Re: how to change the value of session scoped variable
mkouba Jul 31, 2012 5:08 AM (in response to johnnyren)In CDI the content of any context cannot be modified by clients directly. Moreover, unlike Seam bijection (which is performed dynamically) CDI doesn't support outjection as it uses static injection (performed only once per component lifecycle). The CDI way would be to store the variables on a session/request/conversation scoped bean and modify them via setters or other business methods...
-
3. Re: how to change the value of session scoped variable
davidsonrik12 Jul 31, 2012 11:08 AM (in response to mkouba)ok fair enough.
I am assuming that I can still get instances from the context directly using the api in BeanManager ? (to achieve something similar to Contexts.getConversationContext.get("xyz");)
-
5. Re: how to change the value of session scoped variable
mirco898 Aug 3, 2012 7:28 PM (in response to davidsonrik12)Dave,
have you been successful? Can you publish the code or whatever you were able to achieve. That would help us a lot, thanks !
-
6. Re: how to change the value of session scoped variable
rahul22 Jan 21, 2013 1:43 AM (in response to davidsonrik12)hi Dave,
I'm also looking for something replacement of Contexts.getEventContext() in seam 3 . If you got the solution , can you please share it here.
I raised a discussion as well https://community.jboss.org/message/792791#792791.
or any guidance will also be helpful.
Thanks !!
-
7. Re: how to change the value of session scoped variable
jharting Jan 21, 2013 2:39 AM (in response to rahul22)Rahul, see my reply above. You can access the context by calling the BeanManager.getContext(RequestScoped.class) method.
-
8. Re: how to change the value of session scoped variable
rahul22 Jan 21, 2013 3:09 AM (in response to jharting)hi jozef ,
Thanks a lot for reply , i have gone through that link and got the context but in seam 2 i was using contexts to set and get variables.
like:-
Context reqctxt = beanManager.getContext(RequestScoped.class); // in seam 3 i can get like this
nw i want below in seam 3
/////////////////////////////////////////////////////////////////////////////
reqctxt.set("variable_name",variable_value);
reqctxt.get("variable_name");
////////////////////////////////////////////////////////////////////////////
would this be possible ??? in seam 3 ???
Thanks
-
9. Re: how to change the value of session scoped variable
jharting Jan 21, 2013 3:30 AM (in response to rahul22)No, in CDI contexts are "read-only". They are feeded by the application server on demand and you cannot change the value. If you really need to change the value create a holder object and change the value within it.
-
10. Re: how to change the value of session scoped variable
rahul22 Jan 21, 2013 3:40 AM (in response to jharting)hi ,
it will be realy helpful if you can ellaborate the concept of holder object , that your mentioning .
can you give some demo code , for explaining ??.
Thanks a lot !!
-
11. Re: how to change the value of session scoped variable
luksa Jan 21, 2013 5:41 AM (in response to rahul22)@RequestScoped
public class FooHolder {
Foo foo;
void setFoo(Foo foo) {...};
Foo getFoo() {...}
}
@Inject
FooHolder fooHolder;
void bar{
fooHolder.setFoo();
...
fooHolder.getFoo();
}
-
12. Re: how to change the value of session scoped variable
rahul22 Jan 21, 2013 5:47 AM (in response to luksa)hi marko ,
Thanks a lot !!
-
13. Re: how to change the value of session scoped variable
rahul22 Jan 23, 2013 6:47 AM (in response to luksa)hi ,
while going thorugh this holder object approach , i have one question , which is as follows :-
in seam 2 Context we have Contexts.isEventContextActive() similar for all Context .
so when i go for holder approach then do i need to take care of these methods or i can remove them directly ???????
Any help will be good .
Thanks