7 Replies Latest reply on Apr 17, 2007 2:26 PM by sergeysmirnov

    Rerender a t:dataTable using a4j - basic steps

    graflaszlo

      Hi

      I use an AJAX request to use a servlet, wich adds a new item to a
      manages bean's private list. This list is displayed with t:dataTable.

      Can somebody show me the basic steps to rerender a t:dataTable?

      Thank you.
      Laci

        • 1. Re: Rerender a t:dataTable using a4j - basic steps

           

          "graflaszlo" wrote:

          I use an AJAX request to use a servlet, wich adds a new item to a
          manages bean's private list.


          Clarify, please.

          • 2. Re: Rerender a t:dataTable using a4j - basic steps
            graflaszlo

            Hi Sergei,

            1. In my JSP file I have an inputText field, I enter a name into it, then I
            click on AddUgyfelCL or DelUgyfelCL commandLink to add or delete the
            name from a HashSet.

            <t:inputText id="InputAdatlapElozetesUgyfelNeve"
             value=""
             required="#{adatlapelozetesbean.isFelvetel}"
             styleClass="form-text"/>
            <a4j:commandLink id="AddUgyfelCL"
             onclick="AddUgyfel2AdatlapElozetes()"
             reRender="UgyfelekTablaja">
             <t:graphicImage value="../img/add_small.gif" border="0" alt="Hozzáadás" />
            </a4j:commandLink>
            <a4j:commandLink id="DelUgyfelCL"
             onclick="DelUgyfel2AdatlapElozetes()"
             reRender="UgyfelekTablaja">
             <t:graphicImage value="../img/del_small.gif" border="0" alt="Törlés" />
            </a4j:commandLink>


            2. The following JavaScript functions are invoked by the commandLinks:
            function AddUgyfel2AdatlapElozetes() {
             var ajax = new AJAXInteraction("/adatlapelozetes?muvelet=AddUgyfel&ugyfel=1", AddUgyfel2AdatlapElozetesCallBack, new Array());
             ajax.doGet();
            }
            function AddUgyfel2AdatlapElozetesCallBack() {
             //alert("AddUgyfel2AdatlapElozetesCallBack()");
            }
            function DelUgyfel2AdatlapElozetes() {
             var ajax = new AJAXInteraction("/adatlapelozetes?muvelet=DelUgyfel&ugyfel=1", DelUgyfel2AdatlapElozetesCallBack, new Array());
             ajax.doGet();
            }
            function DelUgyfel2AdatlapElozetesCallBack() {
             //alert("DelUgyfel2AdatlapElozetesCallBack()");
            }


            3. The
            /adatlapelozetes
            mapped servlet, locates the
            managed bean using FacesContext and adds the entered name to the
            managed bean's member, wich is a HashSet.

            4. Finally the JSP file displays the the content of this HashSet using
            a t:dataTable. This dataTable I want to rerendered after each
            AddUgyfel and DelUgyfel without to reload the page.

            • 3. Re: Rerender a t:dataTable using a4j - basic steps

              I see the 3rd party code is involved onclick. What this code comes from? I mean what the library you use?

              Also, it is not clean for me why you add additional ajax behavior to ajax link (ie. you will have double Ajax request at once)

              What is a special reason to use 3rd party library here?

              • 4. Re: Rerender a t:dataTable using a4j - basic steps
                graflaszlo

                There is no 3rd party lib. The onclick attributes contain JavaScript functions contained in the JSP page. These functions are Ajax
                interactions and access Java servlets.

                • 5. Re: Rerender a t:dataTable using a4j - basic steps

                   

                  var ajax = new AJAXInteraction("/adatlapelozetes?muvelet=AddUgyfel&ugyfel=1", AddUgyfel2AdatlapElozetesCallBack, new Array());
                  ajax.doGet();


                  Do not say this is embedded functionality Netscape added to javascript dozen years ago.



                  • 6. Re: Rerender a t:dataTable using a4j - basic steps
                    graflaszlo

                    OK. I did know it.
                    Can you help me to rerender that t:dataTable after I add a a new item to
                    that HashSet in the background?

                    • 7. Re: Rerender a t:dataTable using a4j - basic steps

                      If you do not know what you are doing how others can help you.
                      Do you have anybody around you who can explain how the stuff you use work?