Re: how to access JSF Managed Bean in Struts Action class

2004-09-22 Thread Craig McClanahan
Managed beans are no different than any other beans with respect to scopes:
* Managed beans in request scope will be created on demand once for
every request
* Managed beans in session scope will be created on demand once for
every session
* Managed beans in application scope will be created on demand once for the
  lifetime of the application.

If you are caching things that are shared between users, put them in
application scope instead.  If the cached data is unique per user,
then you're going to need to leave it in session scope.

Craig


On Tue, 21 Sep 2004 13:45:58 -0600, BaTien Duong
[EMAIL PROTECTED] wrote:
 
 
 Craig McClanahan wrote:
 
 On Mon, 20 Sep 2004 08:41:55 -0600, BaTien Duong
 [EMAIL PROTECTED] wrote:
 
 
 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?
 
 
 
 I'm not quite sure what you are referring to, but it's quite
 straightforward to reference properties from a session-scoped bean.
 For example, assume user is a UserProfileBean and has a name
 property.  You can use expressions like this:
 
 Hello h:outputText value=#{user.name}/
 
 Note that it doesn't matter whether the bean was created by the
 managed beans facility or via programmatic logic (say, being placed
 there by an Action), so it is very straightforward to interoperate.
 
 
 
 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?
 
 
 
 You can specify initial values for the properties of a managed bean by
 using managed-property elements nested inside:
 
   managed-bean
 managed-bean-nameuser/managedp-bean-name
 managed-bean-classcom.mycompany.UserProfileBean/managed-bean-class
 managed-bean-scopesession/managed-bean-scope
 managed-property
   property-nameuserType/property-name
   property-classjava.lang.String/property-class
   valueStandard/value
 /managed-property
   /managed-bean
 
 The content of the value element can be either a literal value or a
 value binding expression, so you can have your initialization grab
 dynamically calculated values if you need them.
 
 Craig
 
 
 
 Thank Craig. I am fully aware of these features, but found the loading
 is slow. I have not investigated whether faces implementations have some
 caching mechanism so it does not need to create the session managed
 beans from the scratch for every new user.
 
 My question is whether the RI and/or my faces have some caching
 mechanism to speed up the process. If it does not then it is worth while
 to programmatically create these beans from our own cache
 implementation. Once the beans with identical attribute names are
 available in the session then faces does not have to create them. I am
 trying to decide which approach we should take.
 
 Your further insight information may save us some time.
 
 Thank again
 
 BaTien
 DBGROUPS
 
 
 
 -
 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]
 


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



Re: how to access JSF Managed Bean in Struts Action class

2004-09-22 Thread BaTien Duong
Craig McClanahan wrote:
Managed beans are no different than any other beans with respect to scopes:
* Managed beans in request scope will be created on demand once for
every request
* Managed beans in session scope will be created on demand once for
every session
* Managed beans in application scope will be created on demand once for the
 lifetime of the application.
If you are caching things that are shared between users, put them in
application scope instead.  If the cached data is unique per user,
then you're going to need to leave it in session scope.
Craig
 

Thank Craig. I must be too involved NOT to think that way. Thanks a million.
BaTien
DBGROUPS
On Tue, 21 Sep 2004 13:45:58 -0600, BaTien Duong
[EMAIL PROTECTED] wrote:
 

Craig McClanahan wrote:
   

On Mon, 20 Sep 2004 08:41:55 -0600, BaTien Duong
[EMAIL PROTECTED] wrote:
 

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?
   

I'm not quite sure what you are referring to, but it's quite
straightforward to reference properties from a session-scoped bean.
For example, assume user is a UserProfileBean and has a name
property.  You can use expressions like this:
  Hello h:outputText value=#{user.name}/
Note that it doesn't matter whether the bean was created by the
managed beans facility or via programmatic logic (say, being placed
there by an Action), so it is very straightforward to interoperate.

 

  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?
   

You can specify initial values for the properties of a managed bean by
using managed-property elements nested inside:
managed-bean
  managed-bean-nameuser/managedp-bean-name
  managed-bean-classcom.mycompany.UserProfileBean/managed-bean-class
  managed-bean-scopesession/managed-bean-scope
  managed-property
property-nameuserType/property-name
property-classjava.lang.String/property-class
valueStandard/value
  /managed-property
/managed-bean
The content of the value element can be either a literal value or a
value binding expression, so you can have your initialization grab
dynamically calculated values if you need them.
Craig

 

Thank Craig. I am fully aware of these features, but found the loading
is slow. I have not investigated whether faces implementations have some
caching mechanism so it does not need to create the session managed
beans from the scratch for every new user.
My question is whether the RI and/or my faces have some caching
mechanism to speed up the process. If it does not then it is worth while
to programmatically create these beans from our own cache
implementation. Once the beans with identical attribute names are
available in the session then faces does not have to create them. I am
trying to decide which approach we should take.
Your further insight information may save us some time.
Thank again
BaTien
DBGROUPS

   

-
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]
   

-
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]


Re: how to access JSF Managed Bean in Struts Action class

2004-09-21 Thread Craig McClanahan
On Mon, 20 Sep 2004 08:41:55 -0600, BaTien Duong
[EMAIL PROTECTED] wrote:
 
 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?

I'm not quite sure what you are referring to, but it's quite
straightforward to reference properties from a session-scoped bean. 
For example, assume user is a UserProfileBean and has a name
property.  You can use expressions like this:

Hello h:outputText value=#{user.name}/

Note that it doesn't matter whether the bean was created by the
managed beans facility or via programmatic logic (say, being placed
there by an Action), so it is very straightforward to interoperate.

 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?

You can specify initial values for the properties of a managed bean by
using managed-property elements nested inside:

  managed-bean
managed-bean-nameuser/managedp-bean-name
managed-bean-classcom.mycompany.UserProfileBean/managed-bean-class
managed-bean-scopesession/managed-bean-scope
managed-property
  property-nameuserType/property-name
  property-classjava.lang.String/property-class
  valueStandard/value
/managed-property
  /managed-bean

The content of the value element can be either a literal value or a
value binding expression, so you can have your initialization grab
dynamically calculated values if you need them.

Craig

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



Re: how to access JSF Managed Bean in Struts Action class

2004-09-21 Thread BaTien Duong
Craig McClanahan wrote:
On Mon, 20 Sep 2004 08:41:55 -0600, BaTien Duong
[EMAIL PROTECTED] wrote:
 

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?
   

I'm not quite sure what you are referring to, but it's quite
straightforward to reference properties from a session-scoped bean. 
For example, assume user is a UserProfileBean and has a name
property.  You can use expressions like this:

   Hello h:outputText value=#{user.name}/
Note that it doesn't matter whether the bean was created by the
managed beans facility or via programmatic logic (say, being placed
there by an Action), so it is very straightforward to interoperate.
 

   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?
   

You can specify initial values for the properties of a managed bean by
using managed-property elements nested inside:
 managed-bean
   managed-bean-nameuser/managedp-bean-name
   managed-bean-classcom.mycompany.UserProfileBean/managed-bean-class
   managed-bean-scopesession/managed-bean-scope
   managed-property
 property-nameuserType/property-name
 property-classjava.lang.String/property-class
 valueStandard/value
   /managed-property
 /managed-bean
The content of the value element can be either a literal value or a
value binding expression, so you can have your initialization grab
dynamically calculated values if you need them.
Craig
 

Thank Craig. I am fully aware of these features, but found the loading 
is slow. I have not investigated whether faces implementations have some 
caching mechanism so it does not need to create the session managed 
beans from the scratch for every new user.

My question is whether the RI and/or my faces have some caching 
mechanism to speed up the process. If it does not then it is worth while 
to programmatically create these beans from our own cache 
implementation. Once the beans with identical attribute names are 
available in the session then faces does not have to create them. I am 
trying to decide which approach we should take.

Your further insight information may save us some time.
Thank again
BaTien
DBGROUPS
-
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]


Re: how to access JSF Managed Bean in Struts Action class

2004-09-20 Thread Craig McClanahan
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);


 Thanks  Regards,
 Kumar.

Craig

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



Re: how to access JSF Managed Bean in Struts Action class

2004-09-20 Thread BaTien Duong
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]