Sunday, July 20, 2008

Navigating to a new page from an ADF table, on click of a hyper link

You have an ADF table, with one of the colums containing hyperlinks. You may want to navigate to another page, when you click on the hyperlink.


Naturally, If you click on 'name1', you want to see details related to name 1, and not that of the first record (Bug hunt ... TP4). So, you should be able to tell the browser through the framework that, you have clicked on name1 and not some other record. You can achieve it through the following piece of code.
// replace with your iterator.
ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{bindings.ProgramView1Iterator}"); DCIteratorBinding progIter= (DCIteratorBinding)vb.getValue(FacesContext.getCurrentInstance()); //the command link is a child of af:column, which is a child of af:table
// In case of 11g TP3 / TP4 onwards , its RichTable.
CoreTable ct = (CoreTable)actionEvent.getComponent().getParent().getParent(); //access the row data, to obtain the Row object and the formatted key string //oracle.adfinternal.view.faces.model.binding.FacesCtrlHierNodeBinding in 11g TP3 / TP4 JUCtrlValueBindingRef facesCtrlHierNodeBinding = (JUCtrlValueBindingRef)ct.getRowData(); String rowKey = facesCtrlHierNodeBinding.getRow().getKey().toStringFormat(true); prog.setCurrentRowWithKey(rowKey);

No comments: