6 Replies Latest reply on May 30, 2011 7:59 AM by manakor

    How to render <a4j:outputPanel> inside a loop?

    manakor

      Hi I have a loop made with <a4j:repeat>. Inside the loop I have an <a4j:outputPanel> and a link, by clicking on which I wish to render outputPanel, which belongs to current row of the loop.

       

       

      Is there a way to do it with JSF technology?

      Or maybe other ways to get a solution running?

        • 1. Re: How to render <a4j:outputPanel> inside a loop?
          ppitonak

          Hi Nikita,

           

          yes, you can rerender the row  you are on. You can do something like this:

           

          <a4j:repeat value=#{...}" var="...">

             <a4j:outputPanel id="panel">

                // your code

                <a4j:commandButton render="panel"/>

             </a4j:outputPanel>

          </a4j:repeat>

           

          Regards,

          Palo

          • 2. Re: How to render <a4j:outputPanel> inside a loop?
            manakor

            Hi Pavol,

            Is it possible just with <a4j:commandButton>?

            Or I could use <a4j:commandLink> instead?

             

            And how about <a4j:jsFunction> inside every loop, is it going to work:

            <a4j:repeat value=#{...}" var="...">

                 <a4j:outputPanel id="panel">

                      // your code

                      <h:commandLink onclick="renderFunction('param')" value="Click" />

             

                      <a4j:jsFunction name="renderFunction" render="panel" actionListener="#{}" oncomplete="doSmth();">

                           <f:param name="myParam" />

                      </a4j:jsFunction>

                 </a4j:outputPanel>

            </a4j:repeat>

            • 3. Re: How to render <a4j:outputPanel> inside a loop?
              ppitonak

              Hi,

               

              yes, it should work with a4j:commandLink as well. If it doesn't work, it's a bug.

              1 of 1 people found this helpful
              • 4. Re: How to render <a4j:outputPanel> inside a loop?
                manakor

                Have made tests on rendering of needed <a4j:outputPanel> from <aj4:jsFunction>, which is located inside the current loop, but it renders just the outputPanel of the last row of the loop, however I need this one, which is in the same row as the link clicked.

                This is my code:

                <a4j:repeat value=#{...}" var="...">

                    

                     <a4j:jsFunction name="renderFunction" render="panel" actionListener="#{}" oncomplete="alert('Done');">

                          <f:param name="myParam" />

                     </a4j:jsFunction>

                 

                     <h:commandLink onclick="renderFunction('param')" value="Click" />

                    

                     <a4j:outputPanel id="panel">

                          // your code

                     </a4j:outputPanel>

                </a4j:repeat>

                 

                I am using <a4j:jsFunction> just because I have to pass parameters into actionListener of this function. If I could avoid those params, I would use <a4j:commandLink> istead, but I need them. Maybe there's an alternative way how to pass params into <a4j:commandLink> actionListener?

                • 5. Re: How to render <a4j:outputPanel> inside a loop?
                  snaker

                  try out jsFunction outside a4j:repeat

                  • 6. Re: How to render <a4j:outputPanel> inside a loop?
                    manakor

                    Kike, I can not, because I need to render <a4j:outputPanel>, which is located in this particular row of the <a4j:repeat> loop.

                     

                    However, I found a solution assigning parameters to actionListener of <a4j:commandLink>:

                    <a4j:repeat value=#{...}" var="...">

                        

                         <a4j:commandLink actionListener="#{}" render="panel" oncomplete="alert('Done');" value="Click">

                              <f:param name="paramName" value="paramValue" />

                         </a4j:commandLink>

                        

                         <a4j:outputPanel id="panel">

                              // your code

                         </a4j:outputPanel>

                    </a4j:repeat>

                    And this is working for me perfectly - exactly as I was in need!