Friday, March 19, 2010

Taming loooong combo boxes in ADF page Query block

During designing ADF fusion form layout in JDeveloper, sometimes there is a problem with combo boxes in query block:
·          They become too long, as they always try to fit the longest string
·          They change the width randomly as we select other autosubmit elements on which combo boxes are dependent.
 
It can be tamed a bit if you attach specific css class directly on the query, as it is shown here in the following example:

STEP 1:
On your application CSS definition file, add the following class def: 

af|query.queryComboBox af|selectOneChoice::content{
    width: 50px;
}


STEP 2:
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.



Thursday, March 11, 2010

ADF - PL/SQL Procedure or Function Call - Simple and Effective Tool

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.

Download DbCall source code here!

and please leave any comment if you find this code useful ... or whatever...

Welcome

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.

Sasha Stojanovic





Copyright © 2010 Sasha Stojanovic.