Forum Stats

  • 3,851,481 Users
  • 2,263,987 Discussions
  • 7,904,733 Comments

Discussions

InitialFocusId on autosubmit

Sam11116
Sam11116 Member Posts: 355 Blue Ribbon
edited Jan 8, 2014 11:42AM in JDeveloper and ADF

I have dynamic regions(and router calls regions) where I used initialFocusId to set the cursor at desired input component. Issue is when the value is entered on any field which has autosubmit=true, on PPR the focus is set to back to the component which is specified at initialFocusId.

Specs:

Jdev 11.1.1.6

(Mid level knowledge)

Can anybody help me find the blogs or source that solves the issue.

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,725 Red Diamond

    How did you implement the initial focus?

    Timo

  • Frank Nimphius-Oracle
    Frank Nimphius-Oracle Member Posts: 29,689 Bronze Badge

    Hi,

    the initialFocusId is a property on af:document (http://docs.oracle.com/cd/E23943_01/apirefs.1111/e12419/tagdoc/af_document.html). The af:document tag however cannot be used with page fragments but top level documents (JSPX) only. So unless i am mistaken and the same property exists on another component that is allowed for within a region, your usecase is not supported declaratively

    Frank

  • Sam11116
    Sam11116 Member Posts: 355 Blue Ribbon
  • Sam11116
    Sam11116 Member Posts: 355 Blue Ribbon

    Timo, Frank, Could you please help me with this.

  • Sam11116
    Sam11116 Member Posts: 355 Blue Ribbon

    <af:document id="d1" title="IDLM Home" clientComponent="true"

                         initialFocusId="#{focus.focus}">

    ------------------------------------------------------------------------------------------

    public String getFocus() {

       

            UIComponent initialFocus = null;

            FacesContext facesContext = FacesContext.getCurrentInstance();

            String clientId = null;

           

           

           

            if ("ChangeChallengeQA".equalsIgnoreCase((String)this.getExpression("pageFlowScope.switchActivity"))) {

                //        clientId = "r1:1:plam1";

                UIComponent region =

                    facesContext.getViewRoot().findComponent("r1");

                initialFocus = region.findComponent("plam1");

                //           found so use javascript to set the focus

                if (initialFocus != null) {

                    clientId = initialFocus.getClientId(facesContext);

                    ExtendedRenderKitService service =

                        Service.getRenderKitService(facesContext,

                                                    ExtendedRenderKitService.class);

                   

                    service.addScript(facesContext,

                                      " var b = AdfPage.PAGE.findComponent('" +

                                      clientId + "'); b.focus();");

                }

            } else {

                // nothing found then set the startPage focus

                clientId = null;

            }

            focus = clientId;

            return focus;

        }

This discussion has been closed.