3 Replies Latest reply: Jul 23, 2013 10:35 PM by ramandeep singh - oracle RSS

    javascript issue for fragment in jspx page cannot find regionId

    sazz619


      I am using Jdev 11.1.1.4.0

      When i am calling the javascript function its not able to find the region thus my component is not found in the jsff page.

      Please help !!!

       

      Below is my jspx page :-

      <f:view>
          <af:document id="d1" title="Home Page" partialTriggers="pt1">
               <af:resource type="css" source="/com/ge/vacancy/css/GECustomStyle.css"/>

            <af:form id="f1">
              <af:pageTemplate viewId="/com/ge/vacancy/pageTemplate/GEVacancyPageTemplate.jspx"
                               value="#{bindings.pageTemplateBinding}" id="pt1">
              
                <f:facet name="Content">
                  <af:region value="#{bindings.defaultflow1.regionModel}" id="r1" clientComponent="true"/>
                </f:facet>

      </af:form>

             <af:group id="g1">

      <![CDATA[

              <script>

          function charChecker(evt){

      region=AdfPage.PAGE.findComponentByAbsoluteId("r1");

                          if(region!=null)

                              {

                      counter             = region.findComponent("ot17");

                    

                      counter_value       = counter.getValue();

                        }else {

      alert('Region not found')

      }

      }

        </script>]]>

            </af:group>

          

          </af:document>

      </f:view>

       

       

       

      In my frgment jsff page i have the following :

       

      <af:inputText id="it2" rows="08" maximumLength="500"

                                        value="#{bindings.Role.inputValue}"

                                        autoSubmit="true" immediate="true"

                                        partialTriggers="::gli11:soc15" columns="175"

                                        clientComponent="true"

                                        valueChangeListener="#{pageFlowScope.JobDescriptionBean.roleVC}"

                                        binding="#{pageFlowScope.JobDescriptionBean.roleInputText}">

                                        <af:clientListener method="charChecker" type="keyDown"/>

      </af:inputText>

      <af:spacer id="sp22" width="2"/>

                            <af:outputText id="ot17" clientComponent="true"

                                                                                value="500"/>

        • 1. Re: javascript issue for fragment in jspx page cannot find regionId
          ramandeep singh - oracle

          Hi,

           

          Why not use findComponent as in below.

           

          findComp=function(event){
           var source=event.getSource();
           var component=source.findComponent("componentId");
          }
          

           

           

          For this to work the component ot19 which i am assuming is a outputtext has to have value of clientComponent set to true.  Here event will automatically be passed if invoking the component via a clientlistener.

           

          Use findComponentByAbsoluteId only if you know the absolute id of the component. To be sure of the absolute id bind the component to a managed bean and then invoke the javascript as in the example shown below.

           

          public String someAction() {
                FacesContext context = FacesContext.getCurrentInstance();
                ExtendedRenderKitService erks =
                Service.getRenderKitService(context, ExtendedRenderKitService.class);
                erks.addScript(context,"someJSAction('"+textBinding.getClientId(context) +"')"); 
               
                return null;
              }
          

           

          ADF JS

          someJSAction=function(clientId){
          var component= AdfPage.PAGE.findComponentByAbsoluteId(clientId);
          }
          
          • 2. Re: javascript issue for fragment in jspx page cannot find regionId
            sazz619

            This isn't working , any idea how to resolve it , still the region is returning null i.e it cannot find the region .

            I have set the client component to true and tried with findComponent also . aint working.

            • 3. Re: javascript issue for fragment in jspx page cannot find regionId
              ramandeep singh - oracle

              place the javascript in the fragment in af:form and directly use the findcomponent in your function charchecker as shown above. why are you still using region.findcomponent ?