Craig McClanahan wrote:

On Sun, 19 Sep 2004 15:44:14 +0530, ravi naraharasetty
<[EMAIL PROTECTED]> wrote:


Hi All,

How do I access JSF Managed Bean which is in session scope into a
Struts Action Class.




Assume you have a managed bean named "foo" that you'd like to access, of type FooBean.

 FacesContext fc = FacesContext.getCurrentInstance();
 ValueBinding vb = fc.getApplication().createValueBinding("#{foo}");
 FooBean foo = (FooBean) vb.getValue(fc);

Since you have "foo" defined as a managed bean, it will be
instantiated on demand if necessary.

Besides simple expressions like this, you can programmatically
evaluate any legal value binding expression using the technique above.
In addition, value bindings can be used to modify things as well --
if FooBean has a String property named "name", then you can update it
like this:


FacesContext fc = FacesContext.getCurrentInstance(); ValueBinding vb = fc.getApplication().createValueBinding("#{foo.name}"); vb.setValue(fc, "New value for the name");




Hello Craig:

Just 2 quick questions from expert advise. Assuming FooBean is initialized by Faces in the session:
1) Under what cirscunstances we shoud use Faces or directly accessing the component under user session, assuming that you also use faces with other framework such as Tiles?
2) If FooBean is a default user profile bean, does faces have some kind of caching so it can just replicate the default configuration of the user profile for every created user session? If the caching is not a part of spec then which implementation (RI or myfaces) has it?


Thanks.
BaTien
DBGROUPS

Thanks & Regards,
Kumar.



Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

.





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to