Right.
Contextual is there so that frameworks can put stuff in contexts for
"special" cases.
It's not really meant to be used by application code or "normal"
framework code. Stick the stuff in a bean, or use a producer method.
On Thu, May 7, 2009 at 6:10 AM, Pete Muir <pmuir(a)redhat.com> wrote:
Dan and Shane raised the issue of how to store data directly in a
context.
299 includes that facility:
@Current Manager manager;
public void go(final String something) {
// Store the String something in the session context
Contextual<String> somethingContextual = new Contextual<String>() {
public String create(CreationalContext<String> arg0) {
System.out.println("Storing " + something + " in a
context");
return something;
}
public void destroy(String arg0) {
System.out.println("Removing " + something + " from a
context");
}
};
manager.getContext(ApplicationScoped.class).get(somethingContextual,
new CreationalContext<String>() {
public void push(String arg0) {
// No-op, we don't need to deal with partially circularities here
}
});
}
But often, if you are controlling the data object, it's better to use a bean
to manage the data.
--
Pete Muir
http://www.seamframework.org
http://in.relation.to/Bloggers/Pete
_______________________________________________
seam-dev mailing list
seam-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/seam-dev
--
Gavin King
gavin.king(a)gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org