-
1. Re: Accessing a bean from a bean
danielc.roth Feb 15, 2008 2:49 PM (in response to motionfield)sidenote: It is an action not a binding to a value. Bindings to values need get(is)/set. Bindings to actions has the actual method name.
I don't really understand what the problem is: Are you posting guideId to the
showGuide
page? Then you get it with RequestParameter annotation. -
2. Re: Accessing a bean from a bean
motionfield Feb 15, 2008 3:05 PM (in response to motionfield)thanks for your quick reply! ah I see about the get. not very consistent though?
hmm well I guess I could use RP annotation here. but why isn't it possible to use Contexts.getApplicationContext() this way?
we'd like to try to stay away from using requestparameters to hold session data and communicate state data between beans.
say we want to have guideId as a session variable and be able to reach and change it from any bean for this session instead. I read about this in the docs:
Contexts.getSessionContext().set("guideId", 1);
Integer guideId = (Integer) Contexts.getSessionContext().get("guideId");
but where would you define the default value? do you have to use the database and an entity bean? -
3. Re: Accessing a bean from a bean
motionfield Feb 15, 2008 3:41 PM (in response to motionfield)thanks for your quick reply! ah I see about the get. not very consistent though?
hmm well I guess I could use RP annotation here. but why isn't it possible to use Contexts.getApplicationContext() this way?
we'd like to try to stay away from using requestparameters to hold session data and communicate state data between beans.
say we want to have guideId as a session variable and be able to reach and change it from any bean for this session instead. I read about this in the docs:
Contexts.getSessionContext().set("guideId", 1); Integer guideId = (Integer) Contexts.getSessionContext().get("guideId");
but where would you define the default value? do you have to use the database and an entity bean?
-
4. Re: Accessing a bean from a bean
danielc.roth Feb 15, 2008 3:56 PM (in response to motionfield)I don't know if there is a best practice on where to store defaults with Seam (if there is, I'd like to now too).
I (most often) use Seam with spring and simply put default in springs appcontext. You could probably put them in web.xml as a context-parameter as well.
Between requests isn't is easier to @In(scope=...) @Out(scope=...) data rather than Context.get...Context().get/set(data) ?
-
5. Re: Accessing a bean from a bean
motionfield Feb 15, 2008 4:22 PM (in response to motionfield)ok in which docs should I look for more info on web.xml and context-parameters? there doesn't seem to be a whole lot about custom context-params in the seam docs...
I've tried In and Out but I'm having trouble understand exactly what can be injected and outjected and where it goes and can be reached.
my stateless bean could not just inject the stateful one and access it.. maybe if I made it stateful too?
my biggest concern seem to be that I understand the examples and docs pretty well but I don't understand the underlying concepts enough that I know what to do in other cases than the examples present..
-
6. Re: Accessing a bean from a bean
motionfield Feb 15, 2008 4:30 PM (in response to motionfield)btw what does GA and A1 stand for in the version numbers of seam?
-
7. Re: Accessing a bean from a bean
danielc.roth Feb 18, 2008 8:47 AM (in response to motionfield)web.xml is a servlet thingy, not introduced by seam at all.
I look upon In and Out as operations that just put/get stuff from some kind of object space. It is hard to describe easy, without going in to specifics... but the seam documentation is quite good. Playing around is probably the easiest way to get the feel for it.
GA is probably General Availability, and A1
Alpha 1
. (Before beta). Check http://en.wikipedia.org/wiki/Development_stageCheers
-
8. Re: Accessing a bean from a bean
gavin.king Feb 18, 2008 2:31 PM (in response to motionfield)
ah I see about the get. not very consistent though?It is totally consistent. A value binding refers to a get/set pair of a Java-beans-style property, so you would not want to mention the
get
. A method binding refers to an actual method, which need not follow any special naming convention.This is just the basics of unified EL.
-
9. Re: Accessing a bean from a bean
gavin.king Feb 18, 2008 2:36 PM (in response to motionfield)
but why isn't it possible to use Contexts.getApplicationContext() this way?It is possible. If it returns null, it means that there is nothing in the application context with that name.
However, it seems to me that if you're calling getApplicationContext() explicitly, you're either doing something extremely sophisticated, or just not using Seam properly.
What's wrong with injection? Or Component.getInstance()? Why aren't you keeping this state in a Seam component?
Beyond that, I really don't understand what you're trying to do.