Announcement Announcement Module
Collapse
No announcement yet.
Trouble with OGNL Expression in attribute-mapper Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble with OGNL Expression in attribute-mapper

    I am having trouble with an OGNL expression to be used to map an input into a subflow. Basically, an object in flow scope has a Map that contains Lists and I want to pass a specific element in the appropriate List to the subflow based upon request parameters. I have spent some time looking over the OGNL documentation but have not found a solution. Here is the subflow definition:

    Code:
    <subflow-state id="subflow" flow="subflow">
    <attribute-mapper>
    	<input
    		value="$&#123;flowScope.object.map&#91;sourceEvent.parameters.key&#93;&#91;sourceEvent.parameters.number&#93;&#125;" 
    		as="input"/>
    	</attribute-mapper>
    	<transition on="finish" to="finish"/>
    	<transition on="error" to="error"/>
    </subflow-state>
    This produces the following error:

    Code:
    ognl.NoSuchPropertyException&#58; java.util.ArrayList.0
    	at ognl.ObjectPropertyAccessor.getProperty&#40;ObjectPropertyAccessor.java&#58;123&#41;
    	at ognl.ListPropertyAccessor.getProperty&#40;ListPropertyAccessor.java&#58;60&#41;
    	at ognl.OgnlRuntime.getProperty&#40;OgnlRuntime.java&#58;1616&#41;
    	at ognl.ASTProperty.getValueBody&#40;ASTProperty.java&#58;96&#41;
    	at ognl.SimpleNode.evaluateGetValueBody&#40;SimpleNode.java&#58;170&#41;
    	at ognl.SimpleNode.getValue&#40;SimpleNode.java&#58;210&#41;
    	at ognl.ASTChain.getValueBody&#40;ASTChain.java&#58;109&#41;
    	at ognl.SimpleNode.evaluateGetValueBody&#40;SimpleNode.java&#58;170&#41;
    	at ognl.SimpleNode.getValue&#40;SimpleNode.java&#58;210&#41;
    	at ognl.Ognl.getValue&#40;Ognl.java&#58;333&#41;
    	at ognl.Ognl.getValue&#40;Ognl.java&#58;310&#41;
    	at org.springframework.binding.expression.support.OgnlExpression.evaluateAgainst&#40;OgnlExpression.java&#58;35&#41;
    	at org.springframework.binding.support.Mapping.map&#40;Mapping.java&#58;90&#41;
    	at org.springframework.binding.support.ParameterizableAttributeMapper.map&#40;ParameterizableAttributeMapper.java&#58;185&#41;
    	at org.springframework.webflow.support.ParameterizableFlowAttributeMapper.createSubflowInput&#40;ParameterizableFlowAttributeMapper.java&#58;269&#41;
    	at org.springframework.webflow.SubflowState.createSubflowInput&#40;SubflowState.java&#58;230&#41;
    	at org.springframework.webflow.SubflowState.doEnter&#40;SubflowState.java&#58;204&#41;
    	at org.springframework.webflow.State.enter&#40;State.java&#58;189&#41;
    	at org.springframework.webflow.Transition.execute&#40;Transition.java&#58;273&#41;
    	at org.springframework.webflow.TransitionableState.onEvent&#40;TransitionableState.java&#58;230&#41;
    	at org.springframework.webflow.execution.FlowExecutionImpl.signalEvent&#40;FlowExecutionImpl.java&#58;341&#41;
    	at org.springframework.webflow.execution.FlowExecutionManager.onEvent&#40;FlowExecutionManager.java&#58;446&#41;
    	at org.springframework.webflow.struts.FlowAction.execute&#40;FlowAction.java&#58;176&#41;
    	at org.springframework.web.struts.DelegatingActionProxy.execute&#40;DelegatingActionProxy.java&#58;106&#41;
    	at org.apache.struts.action.RequestProcessor.processActionPerform&#40;RequestProcessor.java&#58;419&#41;
    	at org.apache.struts.action.RequestProcessor.process&#40;RequestProcessor.java&#58;224&#41;
    	at org.apache.struts.action.ActionServlet.process&#40;ActionServlet.java&#58;1194&#41;
    	at org.apache.struts.action.ActionServlet.doPost&#40;ActionServlet.java&#58;432&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;709&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
    All of the various changes I attempted to use to fix this problem have resulted in some variation of this error. It seems impossible to have OGNL treat the object retrieved from the map as a Collection.

    If anyone can offer any insight into this problem it would be much appreciated!

  • #2
    I'd recommend running some unit tests with OGNL to see if you can get it to work with that data structure in isolation. To see use of the OGNL API, see the OgnlExpression and OgnlExpressionParser abstractions in the spring-binding code.

    Comment


    • #3
      I think I figured out the problem. It seems that the part of the expression below:

      Code:
      &#91;sourceEvent.parameters.number&#93;
      essentially evaluates to the String

      Code:
      &#91;"0"&#93;
      when the parameter number is 0 since request parameters in this case are Strings. It seems that OGNL does not attempt to convert the value to an int even though the target to evaluate it against is a List. I suppose that behavior is arguable, but the following seems to work:

      Code:
      &#91;@java.lang.Integer@parstInt&#40;sourceEvent.parameters.number&#41;&#93;

      Comment


      • #4
        Didn't know you could do that with OGML

        Cool.

        Comment

        Working...
        X