Monday, May 20, 2013

ADF: How to use af:popup during long running tasks

Suppose the user wants to upload a file. And once he clicks on Upload button, a popup is displayed which actually disables the user input.

For this, create a javascript file and put it in public_html/js folder. Name the file as glassPane.js. These are the contents of the file:
function enforcePreventUserInput(evt) {
    var popup = AdfPage.PAGE.findComponentByAbsoluteId('popupProcessingChanges');
    if (popup != null) {
        AdfPage.PAGE.addBusyStateListener(popup, handleBusyState);

function handleBusyState(evt) {
    var popup = AdfPage.PAGE.findComponentByAbsoluteId('popupProcessingChanges');
    if (popup != null) {
        if (evt.isBusy()) {
        else {
            AdfPage.PAGE.removeBusyStateListener(popup, handleBusyState);

Drop a clientListener component on the button. Set the property 'method' as enforcePreventUserInput, and 'type' as Action.

Now create a popup. Give the id as popupProcessingChanges.
<af:popup contentdelivery="immediate" id="popupProcessingChanges">
        <af:dialog closeiconvisible="false" id="dialogProcessingChanges" title="Processing Changes" type="none">
          <af:panelgrouplayout halign="center" id="pgl1ProcessingChanges" layout="vertical">
            <af:image id="pt_i1" shortdesc="Loading " source="/images/loading.gif">

Also drop a resource component on af:form. Give the 'source' as /js/glassPane.js, and 'type' as javascript.

In case you want to use the javascript file in page template, then please refer this link:

Monday, May 13, 2013

ADF - Programatically Applying and Creating View Criteria

CASE 1: I have already created a view criteria in EmployeeVO, and I want to call it programmatically.
    public void searchEmployee(Number employeeId) {
        ViewObjectImpl vo = getEmployeesView1();
        ViewCriteria vc = vo.getViewCriteria("findEmployeeVC");
        vo.setNamedWhereClauseParam("pEmployeeId", employeeId);

CASE 2: I want to create a view criteria dynamically and execute it programmatically.
    public void searchByEmployeeIdEmail(Number employeeId, String email) {
        ViewObjectImpl vo = getEmployeesView2();
        ViewCriteria vc = vo.createViewCriteria();
        ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
        vcRow.setAttribute("EmployeeId", employeeId);
        vcRow.setAttribute("Email", email);

Thursday, May 9, 2013

ADF - Populate ADF Table using managed Bean and DTO

In this use case, we will be building an employee form where the user will enter details and then click on Save. Once the data is saved, the results will be displayed in the table below.

For every field displayed on the form, we need to declare a variable in the managed bean, and create getters setters.
    private String firstName;
    private String lastName;
    private String email;
    private Date hireDate;
    private String jobID;

Now for every inputField, bind the value property with the variable defined. For example, for the First Name field, I have set the value property as #{pageFlowScope.myBean.firstName}.

This is the method defined in the managed bean for the Save button:
    public void onClickSave(ActionEvent actionEvent) {
        // Add event code here...
        Map searchValueMap = new HashMap();
        searchValueMap.put(FIRST_NAME, firstName);
        searchValueMap.put(LAST_NAME, lastName);
        searchValueMap.put(EMAIL, email);
        searchValueMap.put(HIRE_DATE, hireDate);
        searchValueMap.put(JOB_ID, jobID);

        Map parameters = new HashMap();
        parameters.put("params", searchValueMap);

        BindingContainer bindings = getBindings();
        OperationBinding operationBinding =
        emplist = (List)operationBinding.execute();


This is from the Application module:
    public List saveEmployee(Map params) {
        ViewObjectImpl vo = getEmployeesView1();
        ViewRowImpl vor = (ViewRowImpl)vo.createRow();
        //vor.setAttribute("EmployeeId", params.get("employeeID"));
        vor.setAttribute("FirstName", params.get("firstName"));
        vor.setAttribute("LastName", params.get("lastName"));
        vor.setAttribute("Email", params.get("email"));
        vor.setAttribute("HireDate", params.get("hireDate"));
        vor.setAttribute("JobId", params.get("jobID"));

        List employeeList = null;
        EmployeeDTO employeeDTO = null;
        RowSet rowSet = vo.getRowSet();
        Row row = null;
        if (null != rowSet) {
            employeeList = new ArrayList();
            row = rowSet.first();
            while (null != row) {
                employeeDTO = getEmployeeDTOFromRow(row);
                row =;
        return employeeList;
    private EmployeeDTO getEmployeeDTOFromRow(Row row) {
        EmployeeDTO employeeDTO = new EmployeeDTO();
        return employeeDTO;

For the table, I have set the value property as #{pageFlowScope.myBean.emplist} and binding property as #{pageFlowScope.myBean.empTable}. Getters and setters are created for both:
    private RichTable empTable;

    private List emplist;

Download the sample application from File Cabinet: ProgrammaticTableDTO.rar