Forum Stats

  • 3,851,612 Users
  • 2,264,003 Discussions
  • 7,904,793 Comments

Discussions

Set Focus on CreateINsert row in ADF Table

Umer Farooq
Umer Farooq Member Posts: 28
edited Aug 3, 2017 3:15AM in JDeveloper and ADF

Dear All.

I am using Jdeveloper 12c 12.2.1.2

I want to set focus on newly created row in adf table. I have followed following article.

Andrejus Baranovskis Blog: Improving ADF UI Table CRUD Functionality with Auto Focus

After migrating to 12.2.1.2 this code is still working and the focus is placed in the correct field. but after filling in the EmployeeId and hitting the TAB-key, the input focus is lost, and not placed into the next input field. Any suggestions.

Regards,

Umer Farooq

Tagged:
Daniela Vintu
«13

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,725 Red Diamond
    edited Jan 16, 2017 7:15AM

    Have you checked that the focusID which should be the ID of the next field is correct?

    Timo

  • Umer Farooq
    Umer Farooq Member Posts: 28
    edited Jan 16, 2017 9:58AM

    Yes sir I checked. Also Focus Id is setting correctly and it is also working as per requirement. Problem is after that(When focus is set on required field) on Press Tab Button focus should move to next field. But it does not. Instead it is lost.

  • managed BEAN
    managed BEAN Member Posts: 948 Silver Badge
    edited Jan 16, 2017 11:19AM

    Hello @Umer Farooq

    I had similar problem.

    Try to set t.focus(); twice in your javascript function, and let me know if it worked.

    Regards,

    Carlos

  • Umer Farooq
    Umer Farooq Member Posts: 28
    edited Jan 16, 2017 11:25AM

    @managed BEAN still same result. What I think is by setting focus forcefully, ADF Table lose its internal focus sequence.

  • managed BEAN
    managed BEAN Member Posts: 948 Silver Badge
    edited Jan 16, 2017 11:45AM

    Ok.

    Let´s see.

    Are your requirements to use af:table component compulsory?

    My personal solution (besides double the focus) was to use af:iterator (but af:list also worked), and in the meantime i also used this link: Blog on Software and Beyond it: Set Initial Focus component for Oracle ADF Faces , wich is not mandatory(the major thing in that example is the double focus), but i let it in my code because its used as a component.

    Check my code:

    <af:iterator id="payIter" value="#{viewScope.paymentsTableBean.paymentsTable}" var="item"                         binding="#{viewScope.salePaymentsBean.payIterator}">                <af:panelGroupLayout id="pb1" layout="horizontal">                    <h:outputLabel value="#{labelsVar['LBL-0146']} #{item.index}:" id="ol1" styleClass="paymentLabel"/>                    <af:selectOneChoice id="iteratorTypeCombo" value="#{item.type}" autoSubmit="true"                                        disabled="#{item.index le viewScope.salePaymentsBean.disabledIndex}">                        <?audit suppress oracle.jdeveloper.jsp.validate-children?>                        <f:selectItems value="#{viewScope.salePaymentsBean.paytypeList}" id="si1"/>                        <af:clientListener method="changedPaymentTypeEnter" type="keyUp"/>                        <af:serverListener type="typeFocusListener"                                           method="#{viewScope.salePaymentsBean.paymentTypeChange}"/>                        <ADF-Extensions:setInitialFocus/>                    </af:selectOneChoice>                    <af:inputText value="#{item.amount}" id="iteratorAmount" autoSubmit="true"                                                                    disabled="#{item.index le viewScope.salePaymentsBean.disabledIndex or item.type eq null or item.index ge viewScope.salePaymentsBean.maxNrPayments}"                                  binding="#{viewScope.salePaymentsBean.paymentValueIT}">                        <af:validateDoubleRange minimum="0.01" maximum="#{viewScope.salePaymentsBean.remainingValue}"/>                        <f:convertNumber minFractionDigits="#{currentSessionBean.decimalDigits}"                                         maxFractionDigits="#{currentSessionBean.decimalDigits}"/>                        <af:clientListener method="changedValueEnter" type="keyUp"/>                        <af:serverListener type="valueFocusListener"                                           method="#{viewScope.salePaymentsBean.paymentValueChange}"/>                    </af:inputText>                    <af:link id="linkDelPaym" icon="/resources/images/sales/delete.png"                             actionListener="#{viewScope.salePaymentsBean.deletePayment}"                             rendered="#{item.index gt viewScope.salePaymentsBean.disabledIndex and viewScope.salePaymentsBean.disabledIndex ne 0}"/>                </af:panelGroupLayout>            </af:iterator>

    Also, my data is not coming from DC but programmatically from bean.

    Ah, i used Enter key, but that´s evaluated in javascript:

    function changedValueEnter(evt) {    var keyCode = evt.getKeyCode();    var inputText = evt.getSource();    //check for Enter Key    if (keyCode == AdfKeyStroke.ENTER_KEY) {        var source = evt.getSource();        AdfCustomEvent.queue(source, "valueFocusListener",         {value:inputText.getSubmittedValue()},        false);        evt.cancel();    }}

    Regards,

    Carlos

  • Umer Farooq
    Umer Farooq Member Posts: 28
    edited Jan 17, 2017 4:58AM

    Dear Carlos,

    Thanks for your reply. We have to use af:table as we have already done lot of development on number of forms.

    Secondly I have changed my client script according to your example but result is still same.

    Any help or clue will be highly appreciated. I am in final stages of project and this is must requirement of my client.

    Regards,

    Umer Farooq

  • managed BEAN
    managed BEAN Member Posts: 948 Silver Badge
    edited Jan 17, 2017 9:39AM

    Hello @Umer Farooq

    Sorry. I´m lack of ideas.

    The only hint that i can give now (cause nothing else worked) is that i had to clean code (old stuff and references i didn´t use no more in bean) and only then the example i gave you worked.

    But my case was that i was changing the components from one thing to another(ended up to be af:iterator), and you only migrated from something which was working...

    Best of luck,

    Carlos

  • Umer Farooq
    Umer Farooq Member Posts: 28
    edited Jan 18, 2017 1:15AM

    Dear Carlos

    Thanks a lot for your effort.

  • Umer Farooq
    Umer Farooq Member Posts: 28
    edited Jan 18, 2017 1:16AM

    Do anyone have experience of using jquery with ADF.

    Any helpful hint/workarround will be appreciated.

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,725 Red Diamond
    edited Jan 18, 2017 2:34AM

    Umer, can you provide a reproducible testcase ( ) for this?

    Timo

This discussion has been closed.