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?

4

1 回答 1

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).

于 2015-02-12T05:17:09.307 回答