I created three new helper classes with wide usage potential. In specific cases they can significantly simplify the code and make it re-factoring friendly and even faster because there is no need to reference a view object to get an attribute value. I already use them on my daily ADF tasks.
-----------------------
In short (and exciting)
-----------------------
(1)
Class DynMap
This is helper class to mimic function call from an EL statement, with one passing parameter.
(2)
Class DynMap2
This is a variant of the upper class allowing you to pass two parameters to a function from an EL statement.
Following the same rules you can create corresponding classes to serve 3 and more parameters, too.
(3)
Class DynMapIn
Cool small class to test if some (binding) value is included in a final set of values.
----------------------
In detail (and boring)
----------------------
Currently, EL (Expression language) on ADF platform doesn’t support calling functions with parameters. For example you might want to write a (very logical) function call like this:
...but you can’t do it in ADF. The standard approach is to create a getter on your managed bean, and there to read the attribute from the bindings and do the logic.
And that’s what we usually do, and in most cases it is the only way. A negative consequence of doing it this way is that it that the code cannot be re-factored, because of strings used to reference objects.
I got an idea from how ADF page is using bundles for labels, as it passes a parameter of a key to return associated value. So I used the same idea and constructed a kind of dynamic maps, where the key returned is not a fixed value, but is calculated at the moment of the call. Then I wrapped it all in an easy to use classes.
After updating to JDeveloper 11.1.1.3 on our project, we were surprised to see a new status line below Table in ADF panelCollection component, showing how many columns are hidden. It could be quite useful, but, when there are several tables on the page, this new box takes significant space, and, at least at the moment, I don't see some property to control its appearance.
One simple solution to make it hidden on global level is to add the following code in your CSS definition file:
On the (jspx)page, attach style class directly to the query element:
styleClass="queryComboBox" …
However, be aware that all combos take the same width in the query, as I still don't know if there is a way to control individual combo boxes in queries.
Even ADF Fusion has been brilliantly designed to rescue developers from coding direct calls to PL/SQL procedures and functions, sometime it still has to be done "by hand". After some time of using different techniques, from basic commands to using full frameworks, I finally wrote a helper class named DbCall, which significantly reduces the strain of creating complicated statements. Still, it is very light on code, and easy to expand for any customization you might need.
A few advantages are here:
DbCall can be used equally simple for function and procedure calls.
No need to take care about types of IN parameters.
There is convenient and simple way of handling OUT params.
No need to build complex BEGIN/END PL/SQL string with question-marks.
It greatly simplifies the code you write
There is internal exception handling, but also can be moved externally.
And few examples of "DbCall" in action:
Very simple procedure call with two IN parameters:
DbCall dc = new DbCall("MYPACKAGE.MYPROC", this.getDBTransaction());
//add some carefully created string
dc.addIn("ABC");
//add some integers too, as they are great partners to strings
dc.addIn(123);
//Call it here... Done!!!
dc.execute();
Example of Procedure Call with various IN/OUT parameters:
DbCall dc = new DbCall("MYPACKAGE.MYPROC", this.getDBTransaction());
//add the current user
dc.addIn(this.getUserPrincipalName());
//give a bit of mmh to you...
dc.addIn(this.getMMH());
//everybody needs some time
dc.addIn(new Timestamp(new java.util.Date().getTime()));
//here you cannot go wrong!
dc.addIn(null);
//register this as OUT param as I need it later. dc.addOut("IS_SUMMER",Types.CHAR);
//I need this info too.
dc.addOut("HOW_HOT", Types.FLOAT);
//call it here!!!
dc.execute();
//and here is the summer!
Object Summer = dc.getObj("IS_SUMMER");
//here is how hot it is!
Object Hot = dc.getObj("HOW_HOT");
Example of Function Call with various IN/OUT parameters:
DbCall dc = new DbCall("?:=MYPACKAGE.MYFUNC", this.getDBTransaction());
//the function will return us something, here it goes
dc.addRet("ret", Types.VARCHAR);
//simple simple string as IN param
dc.addIn("ABC");
//some OUT param, as I need to know this.
dc.addOut("RET", Types.FLOAT);
//here is very cool IN/OUT param
dc.addInOut(123,"WHAT",Types.NUMERIC);
dc.execute();
Object ret = dc.getObj("RET");
Object what = dc.getObj("WHAT");
Give it a try!
It is already in use on a big ADF-Fusion project!
DbCall ADF to PL/SQL wrapper is released under the GNU GPL licence and was published on the 12 March 2010.
Hello! My name is Sasha Stojanovic. I am involved professionally in programming from 1990. I've been using many mainstream and even some exotic technologies and frameworks in developing real world applications. I am specialized in creating working bridges in situations when there is no out of the box solution, from audio real-time data processing to enterprise data intensive client and server applications.
I will present here some interesting and (hopefully) reusable programming solutions I have created during my work on real world ADF - Fusion applications.
Hello! My name is Sasha Stojanovic. I am involved professionally in programming from 1990. I've been using many mainstream and even some exotic technologies and frameworks in developing real world applications. I am specialized in creating working bridges in situations when there is no out of the box solution, from audio real-time data processing to enterprise data intensive client and server applications.
I will present here some interesting and (hopefully) reusable programming solutions I have created during my work on ADF - Fusion applications.