Late, but I had the same problem. Ajax is displayed before the completion of my jsf logic. My decision? Well, I added a confirmation dialog. I know this is not a technical solution, but hey, it works. As soon as the user clicks ok in the dialog box (which takes about a second, at this time the logic should be executed), the component should be visualized. Hope this helps.
Before the changes:
<h:commandButton action="#{bean.buisnessLogic(param1, param2)}"> <f:ajax execute="components" render="table" /> </h:commandButton>
After the changes:
<h:commandButton onclick="javascriptCofirm();" action="#{bean.buisnessLogic(param1, param2)}"> <f:ajax execute="components" /> </h:commandButton> <h:commandButton id="button" style="display: none"> <f:ajax render="table" /> </h:commandButton>
JavaScript:
function javascriptConfirm() { bootbox.alert("Se agrego la accion con exito.", function () { var boton = document.getElementById("button"); boton.click(); }); e.preventdefault(); return false; }
What I've done:
So, before the changes were made. My Button command will display a table before adding registers. For example, I would add line 2, and it would not display the changes until the page was refreshed or line 3 was added. I did some research and I came to the conclusion that jsf translates the ajax tag in javascript, and javascript directly executes the code without waiting for the action to complete.
Decision:
So now I remove the render attribute from ajax, and I create another commandButton, and in the new CommandButton I add a render. The javascriptConfirm method calls the button and "clicks" it. This displays the page, but by the time they confirm the logic, it is complete. So yes. This is probably confusing. Itβs good that you just donβt comment, and I will try to answer as quickly as possible (maybe not so fast).
magic source share