How to redirect to an anchor in JSF?

Viewed 6216

Let's say I have this action in a JSF Managed Bean:

public String doSomething() {
    FacesContext.getCurrentInstance().getExternalContext().getFlash().put("msg", "Something was done successfully");
    return "view?faces-redirect=true";
}

My view has an anchor element with the id msg. I want the url to have this anchor (for accessibility matters), like:

view.jsf#msg

Or whatever is my FacesServlet filter pattern.

return "view#msg?faces-redirect=true"; obviously will not work because JSF (mojarra at least) will try to evaluate view#msg as a view.

So my question is how to make JSF redirect to a URL with #msg in the end.

2 Answers
Related