3

I would like to know the difference between calling a service in a transition directly like

<transition name="createExample">
    <service-call name="org.moqui.example.ExampleServices.createExample" in-map="ec.web.parameters"
                  web-send-json-response="true"/>
    <default-response type="none"/>
</transition>

and calling a service inside actions tag like

<transition name="createExample">
    <actions>
        <service-call name="org.moqui.example.ExampleServices.createExample" in-map="ec.web.parameters"
                  web-send-json-response="true"/>
    <actions>
    <default-response type="none"/>
</transition>

How the web parameters are handled in both the cases?

When I am sending a map of arrays in JSON, using AngularJS as input parameters they were getting parsed differently for both the cases.

When the service-call was inside or outside the actions tag the paremeters were being parsed differently for both the cases.

Parameters in JSON 
var parameters = { exampleId : ["example1","example2","example3"]};

ec.web.parameters for service-call in actions tag
exampleId : [example1, example2, example3]

ec.web.parameters for service-call outside actions tag
exampleId : [example1,  example2,  example3]

The elements in the list would contain an extra space for the service outside the action tags.

So is it supposed to work this way?

adityazoso
  • 514
  • 5
  • 15
  • There should be no different in how parameters are parsed, on the server side they go through the same code path. In fact, groovy script for the actions generated in both cases is nearly identical. I've never observed anything like this in doing similar things. To see what is going on I would need enough of your code and such to reproduce it. For debugging I'd recommend looking at the object type and printing the list values individually to see if there really are spaces or there is something else going on. – David E. Jones Feb 22 '15 at 04:15
  • I will try debugging it first and will then get back to you if I have any issues with the complete code that I am using. – adityazoso Feb 23 '15 at 08:58

1 Answers1

1

In both cases you are explicitly specifying the in-parameters to use with the service-call.@in-map attribute, so in this example they are both the same. When the service-call element is directly under the transition element (not inside an actions element) and no @in-map is specified it defaults to the current context, and the same for @out-map. When service-call is inside an actions element there are no defaults for these, i.e. if you want to use the context or some other in- or out-map you must specify them explicitly.

These and many more details about screens, screen transitions, and what forms do when associated with a transition in the Making Apps with Moqui book (which you can download from the moqui.org web site).

David E. Jones
  • 1,721
  • 1
  • 9
  • 8
  • Ok. But I was facing an issue while I was sending in parameters using AngularJS. When my service-call was inside the actions tag in the transition the parameters were parsed differently and when the service-call was outside the actions they were getting parsed differently. – adityazoso Feb 12 '15 at 05:22
  • I have edited the question to provide you with more details of the issue that I am facing currently. – adityazoso Feb 12 '15 at 05:33