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:15 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

March 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 31    
Feb   Apr

Get Firefox!

Wednesday, March 02, 2005

Chatting with a friend in our Partner Technical Services team today, who was in Milan helping a customer figure out their plans for best using our ADF framework, he asked me if I had any examples of defining JClient panels using a metadata-driven approach. As luck would have it, I did have such an example laying around which I've now cleaned up and published as example # 23 on my Not Yet Documented ADF Examples, "SmartPanel Prototype Demo".

A customer asked me a few years ago to demonstrate how they could define databound JClient panels using simple XML files as a way to "design" the screens instead of designing them one by one in the visual designer. I defined an XML Schema called SmartPanel.xsd with a simple XML vocabulary of tags for defining a data-bound panel with an HTML-table style layout, as well as a few simple component types represented by tags named input, label, display, poplist. The SmartPanels project in the workspace contains the base SmartPanel class, which the EmpPanel class in the SmartTest project extends. The SmartPanel uses the SmartBuilder class which implements a SAX filter to dynamically build up the JClient binding objects based on the XML elements found in the panel definition file, as well as the Swing panel controls that are bound to them. The EmpPanel.pnl file in the SmartTest project defines the XML definition of the EmpPanel panel. If you visit the Tools | Preferences... and go to the XML Schema tab, you can add the SmartPanel.xsd file to the list of schemas your IDE is aware of, and relate it to the .pnl file extension. Then you can see how JDeveloper provides in-context, XML-Schema-driven code-insight for the custom XML vocabulary used to define the panels. Try commenting out the line in EmpPanel.java that sets the local to "US" and uncomment the line that sets the locale to Italian, then re-run. You'll see all the prompts show up in Italian. If you select a new department from the poplist, or select a new manager from the poplist, you'll notice how the ADF Business Components reference mechanism automatically refreshes the related information in the panel to show the related new department name, and/or new managers salary. It also causes the recalculation of the calculated attribute showing the current employees salary as a percentage of his/her managers salary. Also interesting is the declarative attribute recalculation going on in the EmpView view object. It extends a custom framework base class named DeclarativeRecalculatingViewObjectImpl, and the EmpView indicates a custom property named Recalc_Mgr with a value of SalaryPercentageOfManager. This declaratively causes the SalaryPercentageOfManager attribute to get recalculated whenever the value of the Mgr attribute gets changed, without having to write custom Java code in the EmpViewImpl class to handle that.

NOTE: I originally developed this example in JDeveloper 9.0.3 and have not upgraded it to use any new ADF binding features, but since we support upward compatibility for 9.0.3 JClient, it worked in 10.1.2 without any changes.


3:37:44 PM    



© Copyright 2008 Steve Muench.