0

Form data is always posted back to the underlying page URL (to save the view state). Is there any way (filter?) we could append request params to the response url, without any redirect ?

For example, I have a page1.xhtml with form data. After submitting the form, let's say, I get the results in page1.xhtml itself. But I needed to have the url modified as page1.xhtml?view=1

Thanks very much.

  • You probably need to perform a GET request after the POST. That's done by a `redirect`. – Aritz Dec 09 '13 at 14:01
  • Yes, that's true. But I want to avoid redirect. May be my question is duplicate of http://stackoverflow.com/questions/10352641/handling-view-parameters-in-jsf-after-post – user3073999 Dec 09 '13 at 14:25
  • hmm... sorry after a re-thinking, this is not the duplicate of http://stackoverflow.com/questions/10352641/handling-view-parameters-in-jsf-after-post. Please suggest if we can really do this. Not sure if prettyfaces can help here? Thanks very much. – user3073999 Dec 10 '13 at 15:50
  • Probably what you need is just a GET request? Why do you say you want to avoid the `redirect`? Having the url changed is only possible using that. With Prettyfaces you can achieve it directly with POST-REDIRECT-GET pattern (defaulted by PF). – Aritz Dec 10 '13 at 16:28
  • Because redirect add one more request for each postback, though minor overhead. – user3073999 Dec 13 '13 at 18:31

1 Answers1

0

I have come up with a solution that seems to work for my use case without any issues. Instead of PostRedirectGet I have used HTML5 History API replaceState to replace the postback url (page1.xhtml) with url with request params (page1.xhtml?view=1) on client side while page rendering. It is supported on IE10+, and latest FF/Chrome, and old browsers (HTML4) with history.js. Please do share your views on this solution. Thanks very much.