5 Replies Latest reply on May 4, 2007 5:54 AM by jul pop

    h:commandLink generation

    jul pop Newbie

      Hi !
      I m new in Ajax4JSF and i m trying to set some h:panelgroup rendered one by one during some filtering steps.

      Here is my specific problem :

      I have the following link launching an ajax request :

      <a4j:commandButton action="#{searchPatientManagedBean.searchPatient}"
       value="Recherche" reRender="searchPatient_panelGroup1"/>


      the method called sets panel render to true, so the table get filled after the click :


      <h:panelGroup id="searchPatient_panelGroup1">
      
      <h:panelGroup rendered="#{searchPatientManagedBean.renderPanelResult}">
       <h:dataTable value="#{searchPatientManagedBean.patients}" var="patient">
      
      ....
      
       <h:column>
       <h:form>
       <h:commandLink action="#{searchPatientManagedBean.showPatient}">
       <h:outputText value="Voir ce patient" />
       <f:param name="patient" value="#{patient}"/>
       </h:commandLink>
       </h:form>
       </h:column>
       </h:dataTable>
      </h:panelGroup>
      
      </h:panelGroup>
      
      <a4j:log height="400" width="200" popup="false" level="ALL"/>
      
      


      The problem occurs when the panelgroud is rendered : the values in the table are correctly populated, but the last form is followed by :
      com.sun.faces.saveStateFieldMarker


      Moreover, when i click on the links created, i get a javascript error :
      curForm has no properties
      clearFormHiddenParams__id28_0__id40("_id28:0:_id40")


      This may be due to the fact that in a4jlog, some javascript is already evaluated during the rendering of my panel :

      debug[17:11:51,402]: Evaluate script replaced area in document: // function clearFormHiddenParams__id28_0__id40(curFormName) { var curForm = document.forms[curFormName]; curForm.elements['patient'].value = null; curForm.elements['_id28:0:_id40:_idcl'].value = null; } // //
      debug[17:11:51,402]: Evaluate script replaced area in document: // function clearFormHiddenParams__id28_1__id40(curFormName) { var curForm = document.forms[curFormName]; curForm.elements['patient'].value = null; curForm.elements['_id28:1:_id40:_idcl'].value = null; } // //

      No errors nor warns happens, as server side.


      If i refresh the page (f5) everything works like i wish, so i may have missed something to avoid this case


      I had already implemented exactly the same page without ajax4jsf, and everyting worked successfully.


      Any suggestion ?
      Thanks

        • 1. Re: h:commandLink generation
          jul pop Newbie

          it seems the problem is the evaluation of the form scripts generated by jsf.

          function clearFormHiddenParams should not be called during the loading of the page, because it modifies the attributes of my form and then crashes the submit.

          I fixed the

          com.sun.faces.saveStateFieldMarker
          error, but cant find a way to disable the script evaluation on rerendering panel !

          Any help ? thanks

          • 2. Re: h:commandLink generation
            jul pop Newbie

            One more info, i ve just tested on IE 6 and it works successfully, but not on mozilla firefox....

            i m a bit lost...

            • 3. Re: h:commandLink generation
              jul pop Newbie

              ok i got the solution and it might help someone else, or maybe there was an easiest way to proceed and i m thinking to complicated :

              here is the solution that i dont understand but that works:


              When i generate the page by Ajax, i have to set manually with a script the name attribute to the form generated. It means that at runtime, javascript set an attribute name to the form.

              That modification is useless if the form is generated without an ajax call, so i guess the problem is the first evaluation of the function "clearFormHiddenParams".

              I think it worked on IE because IE doesnt make a difference between name and id when it looks for a form in the page.


              I hope its gonna help someone else ;)

              • 4. Re: h:commandLink generation
                jul pop Newbie

                form generated by ajax4jsf :

                 <h:form id="totototoot">
                 <script>
                 document.getElementById("totototoot").setAttribute("name","totototoot");
                 alert(document.getElementById("totototoot").name);
                 </script>
                


                • 5. Re: h:commandLink generation
                  jul pop Newbie

                  nevermind it doesnt work, just a problem of firefox cache

                  there is a huge problem i guess but i cant identify it...