Showing posts from February, 2010

A sample ADF BC application based on StoredProcedure

Sometimes you may need to use stored procedures/functions to read/write data from underlying tables. You can still leverage the benefits of ADF persistence layer by smartly wrapping the stored procedures using ViewObjects and EnityObjects. I’m sharing a sample ADF BC application that uses stored procedures for reading and writing to the table. Solution is simple and straight forward... 1. Create an EntityObject and override the below methods protected void doSelect(boolean lock) protected void doDML(int operation, TransactionEvent e) Please refer the below topic in Fusion Developer's Guide to learn more … 38.5 Basing an Entity Object on a PL/SQL Package API 2. Define a ViewObject based on the above EntityObject. Override the below 'life cycle methods' to inject your custom code(for populating data form a REF CURSOR). protected void create() protected void executeQueryForCollection(Object qc, Object[] params, int numUserParams) protected ViewRowImpl c

A common mistake while iterating through <af:table> rows

One common mistake while iterating through the rows of a table is failing to restore the row currency after the iteration. Consider a use case scenario where selected rows of a table need to be processed whenever user does some action. Solution is to stamp each row and process them on by one. The most common mistake here is forgetting to restore the row currency. Wrong Implementation: public void someEvent(ActionEvent actionEvent) { RowKeySet selectedRowKeys = someTable.getSelectedRowKeys(); if (selectedRowKeys != null) { Iterator iter = selectedRowKeys.iterator(); if (iter != null && iter.hasNext()) { Object rowKey =; //stamp row someTable.setRowKey(rowKey); JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)someTable.getRowData(); //Do something here... } } } Ooops...Unfortunately the above code fails with the below error. java.lang.NullPointerException at oracle.adfinternal.view.faces