Forum Stats

  • 3,855,354 Users
  • 2,264,499 Discussions


Set Focus on CreateINsert row in ADF Table



  • William Perez Soto-Oracle
    William Perez Soto-Oracle Member Posts: 16 Employee
    edited Jul 28, 2017 3:54PM

    As Jonas indicated, TAB key navigation in 12c changed. Behavior change to meet WCAG 2.0 and now navigating within the table cells by TAB constitute a trap, hence is disabled by default.

    Workaround in 12c is to set the focus on the cell, then end-user press F2 or ENTER key, this causes the table to enter Actionable Mode and focus moves from the cell to the input field, and while in Actionable Mode when user press TAB, now the focus will move to the next input field.

  • Robert Šajina
    Robert Šajina Member Posts: 94
    edited Aug 2, 2017 4:21AM

    So the solution is pretty simple

    The procedure is the same as explained here: Andrejus Baranovskis Blog: Improving ADF UI Table CRUD Functionality with Auto Focus

    We have found that the solution is to expand the javascript code suggested by Andrejus, so the function for focusing row and field would look like:

    function setFocusByComponentId (id){                  var input = AdfPage.PAGE.findComponentByAbsoluteId(id);            var table = input.getParent();                      input.focus();                      setTimeout(function(){                table.simulateSelectRows(table.getActiveRowKey().toString(),'');             },0);        }
  • Umer Farooq
    Umer Farooq Member Posts: 28
    edited Aug 3, 2017 2:22AM

    Dear ,

    Thanks for reply but following javascript script throwing exception.

    TypeError: table.getActiveRowKey(...) is null

    Can u please check your browser version. I am using firefox. Thanks

    Umer Farooq

  • Robert Šajina
    Robert Šajina Member Posts: 94
    edited Aug 3, 2017 3:15AM

    The table is not getting the right row as active. You have to set active row in java, and than you would be able to set focus on current row.
    It has nothing to do with Browser type.
    In our application we are programmaticlly adding row and setting the current active row.
    If you were using Andrejus sample application, there he is executing operation binding, so ADF is doing the insert.
    So in order this to work you just need to add the following line in the for loop:


    So the function in GenericListener is next:

        public void genericActionListener(ActionEvent actionEvent) {        UIComponent comp = actionEvent.getComponent();        String actionName = (String)comp.getAttributes().get("actionName");                OperationBinding ob = ADFUtils.findOperation(actionName);        if (ob != null) {            ob.execute();        }                RichTable table = this.getRichTableBinding(comp);        if (table != null) {            RowKeySet selection = table.getSelectedRowKeys();            for (Object selectedRowKey : selection) {                String focusComponentTarget = (String)comp.getAttributes().get("focusComponentTarget");                table.setActiveRowKey(selectedRowKey);//this is added to make selection                FacesContext context = FacesContext.getCurrentInstance();                String rowId = table.getClientRowKeyManager().getClientRowKey(context, table, selectedRowKey);                String tableClientId = table.getClientId(context);                String focusId = tableClientId + ":" + rowId + ":" + focusComponentTarget;                                LOGGER.finest("Focus ID: " + focusId);                                ExtendedRenderKitService erks = Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);                erks.addScript(context, "setFocusByComponentId('" + focusId + "')");            }        }    }    

    For us, this works flawlessly with clickToEdit property on table(editingMode). But it should be working on editAll, although its now fully tested.

    Daniela Vintu
This discussion has been closed.