1 2 Previous Next 24 Replies Latest reply on Aug 3, 2017 7:15 AM by Robert Ĺ ajina

    Set Focus on CreateINsert row in ADF Table

    Umer Farooq

      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

        • 1. Re: Set Focus on CreateINsert row in ADF Table
          Timo Hahn

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

           

          Timo

          • 2. Re: Set Focus on CreateINsert row in ADF Table
            Umer Farooq

            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.

            • 3. Re: Set Focus on CreateINsert row in ADF Table
              managed BEAN

              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

              • 4. Re: Set Focus on CreateINsert row in ADF Table
                Umer Farooq

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

                • 5. Re: Set Focus on CreateINsert row in ADF Table
                  managed BEAN

                  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

                  • 6. Re: Set Focus on CreateINsert row in ADF Table
                    Umer Farooq

                    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

                    • 7. Re: Set Focus on CreateINsert row in ADF Table
                      managed BEAN

                      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

                      • 8. Re: Set Focus on CreateINsert row in ADF Table
                        Umer Farooq

                        Dear Carlos

                        Thanks a lot for your effort.

                        • 9. Re: Set Focus on CreateINsert row in ADF Table
                          Umer Farooq

                          Do anyone have experience of using jquery with ADF.

                          Any helpful hint/workarround will be appreciated.

                          • 10. Re: Set Focus on CreateINsert row in ADF Table
                            Timo Hahn

                            Umer, can you provide a reproducible testcase (Writing Reproducible Test Cases: Why and How ) for this?

                             

                            Timo

                            • 11. Re: Set Focus on CreateINsert row in ADF Table
                              Umer Farooq

                              Dear Sir,

                               

                              To reproduce this issue. Simply download application mentioned in following article. and migrate this application to Jdeveloper 12.2.1.2. After that it moves focus on newly created row field. That is as per requirement. But on hitting the TAB-key, the input focus is lost, and not placed into the next input field. It must move to next input field.

                               

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

                              • 13. Re: Set Focus on CreateINsert row in ADF Table
                                Timo Hahn

                                I guess your last option is to open a SR with support.oracle.com (payable support contract needed) and let them work on this.

                                 

                                Timo

                                • 14. Re: Set Focus on CreateINsert row in ADF Table
                                  Muhammad.Rizwan

                                  Hi Umer,

                                   

                                  you can try following

                                   

                                  1. go to xml page, then clean/make project. do this while server is stopped.

                                  2. check if there is duplicate field name

                                  3. try setting focus to some other field.

                                  4. Check properties of next field. e.g.it's not disabled, read-only etc?

                                  5. If everything looks ok, try removing the field and re-create it.

                                      first re-create with same id, if it doesn't work, try creating it with different id.

                                   

                                  good luck!

                                  1 2 Previous Next