Thursday, September 8, 2016

Workaround for ADF 12.2.1.1 Match Media Behavior Tag

If you run ADF 12.2.1.1 application with adaptive UI implemented by af:matchMediaBehavior tag (ADF 12.2.1 Responsive UI Improvements), most likely you will face Null Pointer Exception in Match Media Behavior tag class. Apparently af:matchMediaBehavior tag expects default value to be set on UI component. If default value is not set explicitly, it fails to read it and generates exception (this was not the case in ADF 12.2.1).

This example contains three af:matchMediaBehavior tags, properties orientation and styleClass are not set on panel spitter by default:


This leads into Null Pointer exception on runtime:


To fix this, we can set default values for orientation and styleClass explicitly. Propety styleClass can be assigned with empty value, this helps:


UI is loaded this time:


UI is resized on narrow screen - panel splitter orientation is changed:


Download application with workaround for af:matchMediaBehavior - ADFResponsiveUIApp_v2.zip.

7 comments:

Unknown said...

It is not working in Design mode even after this.
I solved the problem by adding BC4J Service Tester Library to ViewController classpath.
After that it is working fine in Design Mode.

Andrej Baranovskij said...

I doubt if this is related at all.

Regards,
Andrejus

Anonymous said...

Im also facing the same issue with the design mode as mentioned by Shemeer At. Where can I find the BC4J Service Tester Library?

Andrej Baranovskij said...

Why you need to run it in IDE design mode anyway. I always work directly in Source mode.

Andrejus

Anonymous said...

I would like to know the reason why the design mode issue is solved when BC4J Service Tester Library is added to the ViewController classpath. What is the relation between them?

Andrej Baranovskij said...

No idea. This was not a solution for me. And I really doubt there is any relation.

Andrejus

Sushanth Ambala said...

Hi Andrejus,

Am using MatchMediaBehavior for menu and its working fine when I resize the size of the browser manually but its not working when am using some emulators or when I use browser mobile view options. How to test the MatchMediaBehavior ?

Sushanth