Tuesday, February 28, 2012

NullPointerException at ScopeIdAnalyzer - Calling PopUp from Declarative Component

Update: This bug is fixed in upcoming JDev release.

If you develop advanced ADF declarative components, I'm sure sooner or later you would face requirement to implement custom reusable popup. Ideally we would like to invoke custom reusable popup directly from button declared in the fragment or page. This works well on runtime, but JDeveloper 11g R2 IDE generates internal NullPointerException at ScopeIdAnalyzer - I will show how to workaround it.

Sample application provides declarative ADF component with basic popup - CustomPopUp:


Once we drag and drop such component into fragment or page, we can reference ADF popup from inside of declarative component by expanding customPopUp and selecting popup ID. This ID can be mapped with showPopUpBehavior tag to display popup on button click:


This works on runtime, by on design time generates IDE error - once you press OK button to confirm popup ID:


In source mode we can see error description - seems like, JDeveloper is not able to resolve popup ID from declarative component dependency (even it is visible from the wizard):


It works on runtime, but is quite annoying to get NullPointer exception each time when working with page/fragment in IDE. Workaround: invoke popup from declarative component programmatically.

Create binding mapping for custom popup declarative component and action listener mapped with opening button:


From action listener, get instance of declarative component binding, get collection of children and retrieve oracle.adf.Popup family component - show popup:


Popup from declarative component is opened programmatically:


Download sample application (JDeveloper 11g R2) - DeclarativePopUpApp.zip.

6 comments:

Stanislav said...

Hi, Andrejus!
Thank's for very useful informayion.
Can you have an example how to use reusable popup with on the button?

Regards, Stanislav

Andrejus Baranovskis said...

Yes - you can download sample app from this post. Or you are looking for something different?

Andrejus

Stanislav said...

Thank's for answer.
I mean about button with af:showPopupBehavior tag, that invokes reusable popup.

Regards, Stanislav

Andrejus Baranovskis said...

There is such button in the sample :)

Bug is fixed in latest JDev release.

Andrejus

Stanislav said...

Andrejus, in your topic in attached sample(DeclarativePopUpApp.zip) there is a programmatical variant. Can you have a sample with af:showPopupBehavior tag?
I read your topic, created custom reusable popup, but when I drop it onto the page I don't see af:popup element. I use JDeveloper 11.1.2.2.0

Thank you for answer.
Regards, Stanislav

Andrejus Baranovskis said...

You should check second screenshot and text - "Once we drag and drop such component into fragment or page, we can reference ADF popup from inside of declarative component by expanding customPopUp and selecting popup ID. This ID can be mapped with showPopUpBehavior tag to display popup on button click"

You should be able to expand declarative component and select popup.

Andrejus