How to use jsf.ajax.request to manually send ajax request in JSF

前端 未结 3 1895
我在风中等你
我在风中等你 2020-12-05 16:40

I have a table and each row has the \'onclick\' configured to call a js function - this part works. I would like the function to issue an ajax request to a method that I can

3条回答
  •  再見小時候
    2020-12-05 17:17

    Ok, so I managed to implement what I need, with all the ways suggested by BalusC, with looking the best by a wide margin. The reason I am writing a follow up is that there were more things wrong which I initially didn't include in the question and there is not enough comment space ;d

    1. My form was in the wrong place - it was placed within the 'table':

      ......

      Whereas it works for non-Ajax, id doesn't work for Ajax requests. Moving it right below the table caused the requests to be submitted.

    2. The panel that I wanted to render was rendered='false' initially, which caused the HTML markup not to be output in the first place. When the Ajax call returned, it couldn't find an element with the id I wanted to render, and resulted in error dialogs or nothing at all (depending on the method). The solution was to use a wrapper div with the id in question that was always rendered, and use conditional rendering only within that div. So, instead of:

      
        ...
      
      

      I needed to do this:

      
        
          ...
        
      
      

    Thanks for all the help. I will leave the post by BalusC as the correct one as it was really correct, with my own errors influencing the whole thing.

提交回复
热议问题