Wednesday, 4 August 2010

JDev Contextual Events: PayLoad, payload, ah, payLoad

Another blog post along the lines of "this caught me out, cost 2hours of debugging, hopefully you'll learn from my mistakes".

JDev 11g readers will be familiar with the concept of contextual events, a powerful addition that allows task flows embedded in regions to communicate with each other, passing data payloads back and forwards.

Oh, did I say payloads? I meant pay-loads, or is that pay loads? Let's try Pay Loads. Geez what's the difference?

What am I on about?

Within the contextual event framework, effectively there is a "producer" task flow and a "consumer" task flow. The producer publishes a contextual event, and the consumer subscribes to the contextual event. It's all rather handily described in Section 28.7.1 of the Fusion Guide How to Create Contextual Events Declaratively

The publisher can pass a data payload (payLoad, PayLoad, um, pay load?) to the consumer. The publisher users an EL expression to extract data from their local bindings to do this, maybe something like #{bindings.employeeNo.inputValue}, which would be familiar to ADF programmers. The consumer however needs to use an EL expression #{payLoad} to capture the data from the published event.

Now to be specific here the EL expression is "pay" all lowercase, then "Load" with a capital "L" lowercase "oad", not "payload" all in lowercase.

What's the big deal? Well if you do anything else like #{payload} or #{PayLoad}, while the consumer will receive the published contextual event, unfortunately no data gets passed. Of course that's expected behaviour because EL is case sensitive and for whatever ADF internal code is calling behind the scenes, it can't resolve the Java routine name to lookup.

However the problem for developers is, in the English language if you search numerous dictionaries, you'll find the term is "payload", not two words "pay" and "load". It's therefore not intuitive for developers, something people I think will make a mistake on particularly when you read the examples where capital L looks very similar to a lowercase l anyway, and unfortunately, in JDev 11.1.1.2.0 (at least where I tested this) the IDE gives you no warning that you've got it wrong at design time.

So hopefully for readers, forewarned is forearmed (or is that forewarned is forearmed?), and you wont waste an afternoon trying to get something that is in essence very simple to work.

3 comments:

Zee said...

Thanks for advice.

I hope people read this post before searching this blog entry after 2 hours of debugging :)

John Stegeman said...

I think it's supposed to be foreWarned is forArmed :P

Chris Muir said...

I noted my duplicate cut n paste error after posting it, the joke fell flat. But I figured I'd leave it in there to see who commented.

You're the winner John! ;-)

CM.