Reputation: 334
Referencing this question because the problem is identical to mine, but I don't think the solution is usable in my situation.
continuation of pressing button twice
I have a workflow with a series of forms that need to be filled out and submitted, and I would like to display a modal overlay after the user clicks the "next" button. In order to show this overlay, I need to make the command button use ajax. This leads to the undesired behavior as described in the linked issue.
The solution for the linked issue seemed to be "don't use Ajax for navigation", but I think in my case I may have to in order to show this waiting dialogue. Is there any other way to guarantee that the view state on the following page will be updated correctly, so that when I continue navigating I do not need to hit the button twice?
I am using Primefaces 3.3.1.
<p:commandButton id="nextCommand" value="Next"
action="#{backingBean.processInputAndDetermineOutcome}"
onclick="waiter.show();" oncomplete="waiter.hide();">
<f:param name="validate" value="true" />
</p:commandButton>
The "validate" param is a flag I am using in a custom BeanValidator so that my "Back" button can submit the form and update the model without processing any of the valdations. I don't think that should have any impact on this question, but I thought I should mention what other pieces are involved in this commandButton.
Upvotes: 0
Views: 502
Reputation: 1109665
Your best bet is to navigate with a redirect.
public String processInputAndDetermineOutcome() {
// ...
return outcome + "?faces-redirect=true";
}
Otherwise, for sure if you're actually observing the problem in IE browser only and not in other, more sane, browsers, then you may want to try the PrimeFaces-specific JavaScript fix as proposed here: JSF Language switcher and ajax update.
Or, if you're actually observing the problem in <f:ajax>
and not in <p:ajax>
, then try the JSF-specific JavaScript fix as proposed here: h:commandButton/h:commandLink does not work on first click, works only on second click.
Upvotes: 1