4 Replies Latest reply on Sep 30, 2015 8:45 AM by vidyasagar penugonda

    TypeError: f is null from jsf.js when I click on h:commandLink in rich:treeNode

    vidyasagar penugonda Novice

      Hi,

       

      I've got a strange problem with my richfaces tree node. I am doing RF migration from 3.3.3 to 4.5.6 Final. We have a commandLinks which are calling the another page with some parameters and this works fine in RF 3.3.3. we are getting ' TypeError: f is null ' javascript error when I click on command link. Even it is not invoking any action method from bean. Tree is forming without any issues. below is my code.

       

                          <rich:tree id="testTree1" toggleType="client" var="report">                           

                                  <rich:treeModelRecursiveAdaptor id="treeAdaptor"

                                      roots="#{bean.reports}" nodes="#{report.views}">

                                      <rich:treeNode iconCollapsed="/images/spacer.gif" iconExpanded="/images/spacer.gif" iconLeaf="/images/spacer.gif">

                                          <h:outputText id="nodeText" value="#{ report.label }" rendered="#{ report.loadDate == null }" />

                                          <h:commandLink id="nodeText1"

                                              rendered="#{ report.loadDate != null }"

                                              value="#{report.label}"

                                              title="#{report.desc}"

                                              type="submit"

                                              action="#{bean.switchReportPage}"

                                              actionListener="#{bean.processReportName}"

                                              immediate="true"                                  

                                              onclick="useWaitCursor();">   

                                              <f:attribute name="report" value="#{report.label}"/>

                                          </h:commandLink>

                                      </rich:treeNode>

                                  </rich:treeModelRecursiveAdaptor>   

                              </rich:tree>

       

      below are my jars :

      richfaces-4.5.6.Final.jar

      richfaces-a4j-4.5.6.Final.jar

      richfaces-core-4.5.6.Final.jar

      jsf-api-2.2.6.jar

      jsf-impl-2.2.6.jar

       

      Please help me to resolve this. this is stopping my work to move forward. Thanks in advance.

        • 1. Re: TypeError: f is null from jsf.js when I click on h:commandLink in rich:treeNode
          Michal Petrov Master

          Can you disable optimization and paste the part of JavaScript where the error occurs?

          • 2. Re: TypeError: f is null from jsf.js when I click on h:commandLink in rich:treeNode
            vidyasagar penugonda Novice

            Thank you Michal for your response. I disabled the optimization. but still i am getting JavaScript error. below is the code and highlighted the line where I am getting the issue from both(IE8 & FireFox) browsers.

             

            In IE8 I am getting 'Unexpected call to method or property access.'

             

            IE8:

            mojarra.apf = function apf(f, pvp) {

                var adp = new Array();

                f.adp = adp;

                var i = 0;

                for (var k in pvp) {

                    if (pvp.hasOwnProperty(k)) {

                        var p = document.createElement("input");

                        p.type = "hidden";

                        p.name = k;

                        p.value = pvp[k];

                       f.appendChild(p);  // Error Line //

                        adp[i++] = p;

                    }

                }

            };

             

            FireFox ( I am getting - 'TypeError: f is null' error)

            mojarra.apf = function apf(f, pvp) {

                var adp = new Array();

               f.adp = adp;  // Error Line //

                var i = 0;

                for (var k in pvp) {

                    if (pvp.hasOwnProperty(k)) {

                        var p = document.createElement("input");

                        p.type = "hidden";

                        p.name = k;

                        p.value = pvp[k];

                        f.appendChild(p);

                        adp[i++] = p;

                    }

                }

            };

             

            Note: If I disabled the optimization , style classes are not loading and I am getting 'NoClassDefFoundError: org/w3c/css/sac/InputSource' exception.

            • 3. Re: TypeError: f is null from jsf.js when I click on h:commandLink in rich:treeNode
              Michal Petrov Master

              Turning the optimization off was for not having the JavaScript minimized. The f variable is supposed to be the parent form. If you look at the code generated for the link it should be something like <a href="#" onclick="mojarra.jsfcljs(document.getElementById('form'),{'form:j_idt4':'form:j_idt4'},'');return false">link</a> Is your code inside a form? Also are you using h:head? It would explain the missing styles.

              • 4. Re: TypeError: f is null from jsf.js when I click on h:commandLink in rich:treeNode
                vidyasagar penugonda Novice

                Thank you Michal for your response. There is form inside form.. So, I removed the inner form and command link is working fine. and for style exceptions, actually I forget to include sac-1.3 jar. after include this jar, styles are working fine now.