I have a h:commandButton calling some action="#{bean.do}". And also some ajax request for that button which should restyle a part of the website. This restyling should take place before the action is executed. How can I do this?
<h:commandButton action="#{bean.do}">
<f:ajax execute="@form" render="specificId" />
</h:commandButton>
As the action do sometimes takes a long time, I want the page first to display a message/image or likewise. And after that frist execute the action. But how?
You can use the
onclickattribute to execute some JavaScript code right before the action is invoked.E.g.:
It’s however better to use
oneventattribute of<f:ajax>for this, so that you can revert the change:with e.g. this which disables/enables the button and displays/hides the progress image: