I need to prevent it because I'm losing the params from the page when the button is clicked.
This is my code:
<h:commandLink styleClass="ui-btn ui-btn-c ui-icon-arrow-r ui-btn-icon-right" value="Continuar" action="#{metaWEB.btnProximo()}" />
I found some results here, like that How make commandButton not fully refresh page? How to use f:ajax?
But my action use messages from the page, so it need reload the form, but the page not.
I found this thread https://stackoverflow.com/questions/18868130/preventing-jsf-commandbutton-from-reloading-the-page/18868374#18868374
I think could be my solution, but I don't understand what he did :(
Thanks Advanced
Just make it an ajax (asynchronous) button instead of a regular (synchronous) button. It's a matter of nesting a <f:ajax>
inside the existing tag.
<h:commandLink ...>
<f:ajax execute="@form" render="@form" />
</h:commandLink>
The execute="@form"
tells JSF to process the entire form (all input components enclosed in the form the command component is sitting in). The render="@form"
tells JSF to update the entire form as ajax response (so if you display messages inside the very same form, they would be updated as well).
Don't forget to make sure that you return null
or void
from the button's action method, otherwise the view may still change as consequence of a non-null
/void
navigation outcome.
Just remember to change the render="@none" to not reload the page...
<f:ajax execute="@form" render="@none" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With