Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:16:56 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

April 2005
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Mar   May

Get Firefox!

Friday, April 29, 2005

Over on the JDeveloper forum on OTN Jaume asks how he can create a view link between view object instance that live in two different application modules. There are two limitations:

  1. The design time does not present a way to create view link instances in the data model between new VO instances and existing VO instances from nested AM's.
  2. The runtime code appears to me to be making the assumption that the view link usage metadata is refering to a vo usage name in the same AM.

Because of (1) you can't set it up declaratively. Because of (2) even hacking the XML won't be a way to do it. In short, you'll have to do this in code. You could write generic code that leverages some custom metadata properties to setup the view link instance for you based on the usage name of a nested AM. I've uploaded example #33 to my not-yet-documented example page with an example of generic code to accomplish this.


4:36:50 PM    



Yesterday I spent most of the day helping Worldwide Support to diagnose a sporadic problem that a customer was facing in their BC4J/Struts application. The problem only reproduced on one machine, and when JDeveloper was run in the debugger to study the problem further it refused to reproduce. The kinds of errors that the customer was reporting were sporadic errors like:

  • "Component object TheirViewObjectName has no parent"
  • NullPointerException calling findByKey()

This customer was not leveraging the built-in support that BC4J provides for Struts applications to acquire and release the AM instance for you from the pool, and instead was using a home-brew approach to acquire and release the AM needed during the span of each single HTTP request. The problem boiled down to the fact that they were caching the ApplicationModule instance in a private member variable of their Struts Action and this was encountering thread-safety issues. The Struts JavaDoc for the Action class says:

Actions must be programmed in a thread-safe manner, because the controller will share the same instance for multiple simultaneous requests. ... Instance and static variables MUST NOT be used to store information related to the state of a particular request.

when what you save in that private variable is an ADF Business Components application module, funny things can happen when different threads are "peeking" and "poking" at that same private member variable. For example, one thread might free the application module that another thread is just about to use for a findByKey().

I rewrote their code to save the AppModule instance as an HttpServletRequest attribute, and access it from there during the request to avoid these threading issues. This made the sporadic issues go away.

Forewarned is forearmed! :-)


11:21:54 AM    


© Copyright 2008 Steve Muench.