1

I'm using the following action method to make a redirect to the same page.

public String localeAction()
{
    String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
    return viewId + "?faces-redirect=true";
}

This method is called, when a value from a <p:selectOneMenu> holding a list of different languages is selected on the master template.


If the current page URL has some query-string parameters appended to it like so,

http://localhost:8080/Project/public_resources/ProductDetails.jsf?id=5

The parameter id is lost after this redirection has been made.

Is there a way to redirect to the current page along with all query-string parameters intact - they should not be lost?

Tiny
  • 27,221
  • 105
  • 339
  • 599
  • Try appending the returning outcome with: "includeViewParam" like this : `?faces-redirect=true&includeViewParams=true` as described here: http://stackoverflow.com/a/17745573/2459449 – Omar Apr 09 '14 at 06:59
  • The problem arises with request scoped managed beans where appending `includeViewParams` to `ViewId` doesn't work. The action method is invoked, on the `onchange` event of `` (which is an AJAX request) which is located at the master template. It seems I have to decorate all managed beans with `@ViewScoped` throughout the application. – Tiny Apr 09 '14 at 07:48
  • I think you'd decorate just those associated with views that use the Ajax's fonctionnality. – Omar Apr 09 '14 at 08:02
  • The `onchange` event of `` is an AJAX request as always which is located at the master page template. Hence, it is available to all pages associated with that template. Therefore, it needs view scoped beans everywhere. – Tiny Apr 09 '14 at 08:07
  • Does it work for view scoped managed-beans ? – Omar Apr 09 '14 at 08:15
  • Yes it works for view scoped beans. – Tiny Apr 09 '14 at 08:17

0 Answers0