I have a viewscoped bean wich receives parameters through f:viewparam and set values in the model using them. After a page postback, the parameters dissapear from the url but the model values setted by the initial params are retained somehow.
Is this a safe way of keeping parameters or should I rewrite the url on postback so it keeps the initial parameters subsequent calls?
How are the parameter retained? In the viewstate?
Here's what the f:viewParam documentation says:
This means that the
<f:viewParam>
value
attribute will be updated with the request parameter, stored in the viewstate and re-set/revalidated when you submit the page again.Arjan Tijms has the full story here: http://arjan-tijms.omnifaces.org/2011/07/stateless-vs-stateful-jsf-view.html
In short: using a
@ViewScoped
bean is perfectly fine, but if you use an expensive validator/converter on that value be aware that it will be called again on each postback from that page. If you want to avoid that, have a look at this article from BalusC, which explains o:viewParam, OmniFaces' stateless alternative.