Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: RE: Still facing problems in accessing the beans in scopes other than flow scope.

  1. #11
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Default

    Quote Originally Posted by shashi View Post
    Is there any other scope (like request) where the bean life cycle will be managed by spring and the bean instance won't be available after the authentication action is over. I want to know more about the scope similar to request here.
    In this particular instance then, why not just use request scope? It seems it would fulfill your needs exactly.

    -Jeremy

  2. #12
    Join Date
    Jul 2006
    Posts
    126

    Default

    Hi Jeremy,

    Thanks for your reply.

    To use a bean in request scope, I think I don't have to define any scope for the bean, the way mentioned below:

    <bean id="login" class="MyLoginClass"/>

    and access the bean in the jsp as

    <h:inputText id="loginid" value="#{login.id}"/>
    <h:inputText id="password" value="#{login.password}"/>

    However I still get the bean as null in the request scope. Is there anything I am doing here?

    Thanks once more for your help,
    Shashi

  3. #13
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Default

    You need to explicitly specify request scope. The config you show will use the Spring default of singleton scope, which is definitely not what you want.

    Keep in mind that http request scope and flow request scope (that accessible through RequestContext) are two different things. When you define your bean as:

    Code:
    <bean id="login" class="MyLoginClass" scope="request"/>
    you are defining it in http request scope. If you are trying to then manipulate it from your intermediary action, the cleanest and easiest thing is to use Spring's dependency injection. On the other hand, if you for some reason defined the bean as a JSF managed bean in request scope, you could use the same code as I described before where you try to access the bean using JSF's variable resolution mechanism.

    -Jeremy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •