Displaying Current row in ADF Page
Through this article, I will explain how to access the current row of an ADF application which has multiple rows in the ADF table.
package tgr.oracle.apps.fnd.CurrentRowADF;
import javax.faces.event.ActionEvent;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
public class CurrentRowManageBean {
public CurrentRowManageBean() {
}
public void CurrentRowBtnEvt(ActionEvent actionEvent) {
// Add event code here...
System.out.println("Select One Button has been Clicked");
// Get bindings associated with the current scope, then access the one that we have assigned to our table - e.g. OpenSupportItemsIterator
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItteratorBindings =
bindings.findIteratorBinding("EmployeeInfo1Iterator");
// Get an object representing the table and what may be selected within it
ViewObject voTableData = dcItteratorBindings.getViewObject();
// Get selected row
Row rowSelected = voTableData.getCurrentRow();
// Display attribute of row in console output - would generally be bound to a UI component like a Label and or used to call another proces
System.out.println(rowSelected.getAttribute("EmployeeId"));
System.out.println(rowSelected.getAttribute("EmployeeName"));
System.out.println(rowSelected.getAttribute("Designation"));
System.out.println(rowSelected.getAttribute("Location"));
}
}
Run the application to select the current row and press the Button to display current values in the console.
Let's create a sample application, Here my application name is CurrentRowADF and add Business components such as View Object and Application module
I'm creating a View object with below query
select * from xx_employee_info
Below is the table structure
Below is the table structure
Creating a View Object
Creating a ADF Table with single row selection
Add a button to print current values
Create Action listener on the button to print current row values
package tgr.oracle.apps.fnd.CurrentRowADF;
import javax.faces.event.ActionEvent;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
public class CurrentRowManageBean {
public CurrentRowManageBean() {
}
public void CurrentRowBtnEvt(ActionEvent actionEvent) {
// Add event code here...
System.out.println("Select One Button has been Clicked");
// Get bindings associated with the current scope, then access the one that we have assigned to our table - e.g. OpenSupportItemsIterator
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItteratorBindings =
bindings.findIteratorBinding("EmployeeInfo1Iterator");
// Get an object representing the table and what may be selected within it
ViewObject voTableData = dcItteratorBindings.getViewObject();
// Get selected row
Row rowSelected = voTableData.getCurrentRow();
// Display attribute of row in console output - would generally be bound to a UI component like a Label and or used to call another proces
System.out.println(rowSelected.getAttribute("EmployeeId"));
System.out.println(rowSelected.getAttribute("EmployeeName"));
System.out.println(rowSelected.getAttribute("Designation"));
System.out.println(rowSelected.getAttribute("Location"));
}
}
Run the application to select the current row and press the Button to display current values in the console.
Comments
Post a Comment