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-name>user</managedp-bean-name>
  <managed-bean-class>com.mycompany.UserProfileBean</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
    <property-name>userType</property-name>
    <property-class>java.lang.String</property-class>
    <value>Standard</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]



Reply via email to