PDA

View Full Version : help on xml output subflow-state definition (OgnlException)



geideon
Jun 10th, 2005, 07:15 AM
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:


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.getFlowS cope().getAttribute("demandeadhesionmensualisation");
String identifiant=demande.getAvisimposition().getContrib uableparticulier().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=selection&refavis=666">Avis 666</a>



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



<attribute-mapper>
<input name="$&#123;demandeadhesionmensualisation.avisimposition.con tribuableparticulier.identifiant&#125;" as="identifiant"/>
<output value="$&#123;sourceEvent.parameters.refavis&#125;" as="$&#123;demandeadhesionmensualisation.avisimposition.ref erence&#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.

Keith Donald
Jun 10th, 2005, 05:43 PM
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.avisimposition.refer ence"/>

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.

klr8
Jun 11th, 2005, 02:01 AM
Are there any exceptions? Or is it just not mapping properly?

Erwin

geideon
Jun 11th, 2005, 09:10 AM
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.avisimposition.refer ence"/>
) 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.

geideon
Jun 14th, 2005, 08:12 AM
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.ref erence}"/>

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