Results 1 to 5 of 5

Thread: help on xml output subflow-state definition (OgnlException)

  1. #1
    Join Date
    Mar 2005
    Posts
    14

    Default help on xml output subflow-state definition (OgnlException)

    Hello,

    When my subflow ends, i need to write an attribute of a bean which is in the parent flow scope.
    Using a bean subclassing a ParametrizableAttribueMapper and referenced in the subflow state, i succeeded. Trying to do the same thing using only xml descriptions of the mapping i get an ognl exception.

    Here the code for the mapper defined as a bean and referenced in the subflow state:
    Code:
    public void mapSubflowOutput(RequestContext rc) {
    		String ref=(String)rc.getSourceEvent().getParameter("refavis");
    		Scope parentScope=rc.getFlowContext().getActiveSession().getParent().getScope();
    		DemandeAdhesionMensualisation demande=(DemandeAdhesionMensualisation)parentScope.getAttribute("demandeadhesionmensualisation");
    		demande.getAvisimposition().setReference(ref);
    		super.mapSubflowOutput(rc);
    	}
    
    	public Map createSubflowInput(RequestContext rc) {
    		
    		DemandeAdhesionMensualisation demande=(DemandeAdhesionMensualisation)rc.getFlowScope().getAttribute("demandeadhesionmensualisation");
    		String identifiant=demande.getAvisimposition().getContribuableparticulier().getIdentifiant();
    		rc.getRequestScope().setAttribute("identifiant",identifiant);
    		return super.createSubflowInput(rc);
    	}
    the "refavis" is received when the user clicks on a link in a subflow view

    <a href="sub.flow?_flowExecutionId=0A&_eventId=select ion&refavis=666">Avis 666</a>



    Here the xml that i tried to do the same thing:

    Code:
    <attribute-mapper>
    			<input name="$&#123;demandeadhesionmensualisation.avisimposition.contribuableparticulier.identifiant&#125;" as="identifiant"/>
    			<output value="$&#123;sourceEvent.parameters.refavis&#125;" as="$&#123;demandeadhesionmensualisation.avisimposition.reference&#125;"/>
    		</attribute-mapper>

    With this definition, i get an OgnlException for the output arguing that sourceEvent is null. (getProperty(null,parameters)) but the sourceEvent in the java code isn't null... bug ?

    Thank you in advance.

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

    Default

    Hmm... well, by xml you're defining your mapper in SPRING bean xml, not a subflow state of a webflow xml definition. Such usage from the webflow def will definitely read better....

    Is "reference" a property in the subflow's flow scope? It looks to me like it's an event parameter.

    I'm not sure what you're doing but if you're trying to map a 'reference' attribute in subflow scope to the parent it would look like:

    <entry key="${flowScope.reference} value="demandeadhesionmensualisation.avisimpositio n.reference"/>

    What a long name for a property! I hope you know what it means :-)

    The entry value is the target path to the attribute value returned from the key expression. The key expression evaluates the flow request context if enclosed in an expression ${} placeholder, otherwise it operates on flow scope.
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Are there any exceptions? Or is it just not mapping properly?

    Erwin

  4. #4
    Join Date
    Mar 2005
    Posts
    14

    Default

    the bean defined in spring xml is referenced in an attribute mapper of a sub flow state.
    The "reference" is a property of the subflow scope (posted by a form).
    The syntax you proposed (<entry key="${flowScope.reference} value="demandeadhesionmensualisation.avisimpositio n.reference"/>
    ) was logically and intuitively what i put in first but i get everytime an ognl exception. I tried also ${sourceEvent.parameters.reference} or ${lastEvent.parameters.reference} or ...
    so i tried with a java implementation of the attribute mapper to figure out if i could do the output mapping.

    Your phrase "The key expression evaluates the flow request context if enclosed in an expression ${} placeholder, otherwise it operates on flow scope" should help me a lot, thanks for this comprehension tip, i will retry on monday.

    Felicitations to clever people developping this great framework.Wish it long life.

  5. #5
    Join Date
    Mar 2005
    Posts
    14

    Default

    I edited the description of my problem.
    To resume, if i put this xml definition in the attribute mapper subflow definition :
    <output value="${sourceEvent.parameters.refavis}" as="${demandeadhesionmensualisation.avisimposition .reference}"/>

    the sourceEvent is null (ognl exception)

    If i do the same thing with a ParameterizableFlowAttributeMapper, i am able to retrieve the parameter refavis from the requestContext.getSourceEvent()

    Any idea ? Thanks

Similar Threads

  1. Replies: 4
    Last Post: Jun 11th, 2009, 12:13 PM
  2. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  3. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  4. Beandoc crashing (on its samples!)
    By aaime in forum Container
    Replies: 17
    Last Post: Oct 7th, 2005, 07:21 AM
  5. Replies: 3
    Last Post: Aug 31st, 2005, 04:26 AM

Posting Permissions

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