Results 1 to 3 of 3

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

  1. #1
    Join Date
    Jul 2006
    Posts
    126

    Default Still facing problems in accessing the beans in scopes other than flow scope.

    Hi,

    Please refer to my earlier post at http://forum.springframework.org/showthread.php?t=38685

    I have tried using the SWF 1.1 nightly build.
    I have specified the login bean as

    <bean id="login" class="MyLoginBeanClass" scope="flash"/>

    The spring identifies the scope flash. However in the next action when I try to retrieve the bean in the flash scope, I get null value.

    I understand that login bean has not been instantiated, however since I am using it on the page for the first time, shouldn't it be instantiated by the framework while doing the data binding?

    I have pasted below the configuration I did in the faces-config file.

    <?xml version="1.0"?>

    <!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

    <faces-config>
    <application>
    <!-- Navigation handler proxy for a Spring-managed bean that is the Web Flow Navigation Handler -->
    <navigation-handler>
    org.springframework.webflow.executor.jsf.FlowNavig ationHandler
    </navigation-handler>
    <property-resolver>
    org.springframework.webflow.executor.jsf.FlowPrope rtyResolver
    </property-resolver>
    <variable-resolver>
    org.springframework.webflow.executor.jsf.FlowVaria bleResolver
    </variable-resolver>
    <variable-resolver>
    org.springframework.web.jsf.DelegatingVariableReso lver
    </variable-resolver>
    <!-- Extended "webApplicationContext" resolver -->
    <variable-resolver>
    org.springframework.web.jsf.WebApplicationContextV ariableResolver
    </variable-resolver>
    </application>
    <lifecycle>
    <!-- Multi-caster that broadcast phase events to all PhaseListeners managed by Spring -->
    <phase-listener>org.springframework.webflow.executor.jsf. FlowPhaseListener</phase-listener>
    </lifecycle>
    </faces-config>

    If I use flow scope instead of flash, everything works fine. However the similar configuration should have worked in flash scope as well. Am I doing anything wrong here?

    Would appreciate your help here.

    Regards,
    Shashi

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Shashi,

    If you try and lookup the attribute from an action using the RequestContext it doesnt go through the same variable resolution strategy--it will simply query the flash map directly. Thus far this feature has been designed for use when JSF components reference the bean by name in their value binding expressions e.g. #{foo.bar}.

    Keith
    Keith Donald
    Core Spring Development Team

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

    Default

    Keith makes a good point that the creation-on-demand of the beans is achieved by using the JSF expression mechanism. You can take advantage of this in your authentication action, so that instead of trying to get the login bean via:

    Code:
    requestContext.getFlashScope().get("login");
    you can get it (and have it created on demand) by using:

    Code:
    FacesContext context = FacesContext.getCurrentInstance();
    MyLoginClass login = context.getApplication().getVariableResolver().resolveVariable(context, "login");
    -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
  •