Tuesday, December 25, 2012

Contextual Event - Interface based Consumer - NO DataControl Yey!

In my last blog, I showed how using an interface as a parameter will allow you to decouple your ADF beans even more.

A couple days before Christmas, somebody in EMG forums asked about ADF utilizing too many pageDefinition files. This led me to a link by Steve Muench's blog #164 - His example basically demonstrates how you can have a manage bean be defined as an instance method in your pageDefinition.

So this gave me the idea to upgrade my earlier blog to use this so that we will ultimately clean up the amount of files generated in our project.

I highly recommend to go through my previous blog since it involves showing the invocation and the initial use case of the listener interface. This time though, I'll be showing the handler interface.

First create an interface which our bean will implement. This interface will be defined by the requestScope bean which will represent the instance name of the pageDef. If you notice in Steve's blog, he pointed out how to use this method binding properly, the instance name has to use the $ notation for its EL Expression oppose to the normal # (I'm still looking for more resources to explain this) - just in case, this means you can't use ${requestScope.<Bean>} you have to call it ${<Bean>}.

Interface Handler

Uhm.. the request scope part is only because there is no point using a bigger scope for something that is only used as needed.

Request Bean

So here's the screenshots.

Event Mapping - pageDef
And just in case you're curious which lifecycle it lands, here's the console logger of the lifecycle.

Invoke Application Phase

No comments:

Post a Comment