Using lastReturn

Every tag inside a handlers block generates a "lastReturn" that can be used by the immediately next tag. While most tags do not return any value, you can make your method invokers take advantage of it.

If your function call returns something other than void, that value will be stored in the scope's "lastReturn" value. This value can be used by other tags as they would use the event, the result object or server faults. This value will be null if your function returns void.

For example, say you have a class that calculates shipping costs and you want to send that value along with other things to the server. So your function would look like:

public function calculateShipping(weight:Number):Number {
   //do calculation
   return someNumber;
}

In your handlers block, you will call your class and then send the information to the server:

<MethodInvoker generator="{MyClass}" method="calculateShipping" arguments="{[event.itemWeight]}" />

<WebServiceInvoker arguments="{[lastReturn, event.itemId]}" .....service attributes....>
   ...
</WebServiceInvoker>

Because your method call returned a value, the next tag (the WebServiceInvoker) can use it.

More information at Using Smart Objects (lastReturn).

0 responses so far

Leave a response

If you need help or want to comment on something not related to this page, please post in the forums. Thanks!