1 2 Previous Next 17 Replies Latest reply on Mar 9, 2011 8:33 AM by ram ram

    JS function is not working

    ram ram Newbie

      Dear All,

       

      I m facing a problem with JS function in <rich:dataTable> on page flipping the JS function is not working anymore it works only on first page of the table. any help is appreciated

       

      below is a the code :

       

      <rich:dataTable value="#{documentUploadBB.selectedDocument.attachedFilesLst}" var="file" id="filesTbl">

               <rich:column>

                     <f:facet name="header">

                             <h:outputText value="" />

                      </f:facet>

                  <h:selectOneRadio value="" onclick="selectOneRadio(this)" id="checked">

                        <f:selectItem itemValue=""/>

                           <a4j:support event="onmousedown" reRender="specificPriviliegesPanel,roleList,documentUsersModal"                                                        action="#{documentUploadBB.selectFile}">

                                            <f:setPropertyActionListener value="#{file}" target="#{documentUploadBB.selectedFile}"/>

                            </a4j:support>

                           </h:selectOneRadio>

              </rich:column>

                       .

                      .

                      ........................................   

       

             <f:facet name="footer">

                                                                                                                                                                                <rich:datascroller align="center" for="filesTbl" renderIfSinglePage="false" id="filesDS" />

             </f:facet>

      </rich:dataTable>

        • 1. JS function is not working
          Ilya Sorokoumov Master

          As a workaround you can add some specific css style for h:selectOneRadio and use JQuery for adding onclick handler in rich:datascroller's oncomplete event.

          • 2. JS function is not working
            Nick Belaevski Master

            Hi,

             

            I am not able to locate a4j:jsFunction in the posted code - am I missing something?

            • 3. JS function is not working
              ram ram Newbie

              Hi Nick,

               

              the JS function is called when clicking on the radio button (onclick="selectOneRadio(this)") , this is working properly only on the first page of the data table when flipping to the next page the JS function is not working anymore.

               

              Regards,

              • 4. JS function is not working
                ram ram Newbie

                Hi Ilya,

                 

                I dont know if u got my problem " The JS function is working properly only on the first page of the data table when flipping to the next page the JS function is not working anymore."  (  <h:selectOneRadio value="" onclick="selectOneRadio(this)" this is how the JS function is called ). I have this as a general behvior in all the application and i need a general work around to fix it.

                 

                Thanks for ur help

                • 5. JS function is not working
                  Nick Belaevski Master

                  Where is jsFunction located: inside table or outside it?

                  • 6. JS function is not working
                    ram ram Newbie

                    The jsFunction is located inside the table.(please refer to the code posted above)

                    • 7. JS function is not working
                      Nick Belaevski Master

                      But I can't locate a4j:jsFunction there - maybe the code got crippled after paste to the forum?

                      • 8. JS function is not working
                        ram ram Newbie

                        OK i  got ur point the jsFunction is located in a js file. here is the missing part of the code

                         

                         

                        <head>

                                  <script type="text/javascript" src="/ipmSuite/javascript/adm/doc/FrmDocumentUpload.js"></script>

                        </head>

                         

                         

                        here is the function body (located in  FrmDocumentUpload.js)

                         

                        function selectOneRadio(param) {

                         

                                                 cnt = 0;

                                                 while (document.getElementById("documentUploadFrm:filesTbl:"+cnt+":fileName") != null)

                                                 {

                                                           document.getElementById("documentUploadFrm:filesTbl:"+cnt+":checked:0").checked = false;

                                                           if (document.getElementById("documentUploadFrm:filesTbl:"+cnt+":checked").id+':0' == param.id)

                                                                {

                                                                          document.getElementById("documentUploadFrm:filesTbl:"+cnt+":checked:0").checked = true;

                                                                }

                                                           cnt++;

                                                  }

                                  }

                         

                        Thanks for ur help Nick

                        • 9. JS function is not working
                          ram ram Newbie

                          Any updates on the above issue. any help is appreciated

                           

                          Thanks

                          • 10. Re: JS function is not working
                            Nick Belaevski Master

                            Obviously

                             

                            (document.getElementById("documentUploadFrm:filesTbl:"+cnt+":fileName") != null)

                             

                            is true for the first page only. Use jQuery/Prototype to traverse the nodes - it will be much more supportable.

                             

                            BTW, cnt is global variable in your case - should be made local.


                            • 11. JS function is not working
                              ram ram Newbie

                              Thanks a lot for your help Nick, i really appreciate it. can you provide me with useful  references since i am new to jQuery.

                               

                              Best Regards,

                              • 12. JS function is not working
                                Nick Belaevski Master

                                Sure, http://jquery.com/ has lot of useful documentation.

                                • 13. JS function is not working
                                  ram ram Newbie

                                  Hi Nick,

                                   

                                  Let me re-explain what is going wrong with my application. In the datatable i have to select only one row so i added a radio button on each row and manage using a JS function in order to allow only once selection. This function is working well unless the first page is flipped, the JS function is not working anymore on the next pages.

                                   

                                  As per your advice i used jQuery and the problem is still reproduced. Jquery function works properly until the first page is flipped.

                                   

                                  I was checking JQuery tutorial in Live Demo and i encoutered the same problem that i m facing. I applied "Zebra-styled table with rich:jQuery example". In my application the style was applied correctly to the "rich:dataTable"  but when i flipp the page the zebra style is not appliad anymore and the old style appears again.

                                   

                                  http://livedemo.exadel.com/richfaces-demo/richfaces/jQuery.jsf

                                   

                                  This is exactly the same problem i m facaing now. when I flipp the rich:dataTable page the jQuery is not working anymore it is only applied to the first page.

                                   

                                  Please let me know that is ur opinion concerning this problem.

                                   

                                  Regards,

                                  • 14. JS function is not working
                                    Nick Belaevski Master

                                    How does page code look like now?

                                    1 2 Previous Next