For instance, say I want to run some logic and then hit /page.html#elementid
<h:commandLink action="#{myBean.action}" value="Go"/>
and
public String action()
{
// Some logic here
return "/page.xhtml#elementid";
}
I cannot find any examples regarding this, and wonder if there is a solution?
The
#elementidURI fragment has to be sent to the client side as well. This is not happening here. You’re basically performing a server-side forward. You should be performing a client-side redirect instead.Alternatively, you could conditionally render some JavaScript to set the URI fragment:
with in
page.xhtml:The
<h:link>by the way has explicit support for URI fragments.It however fires a GET request, so any preinitializing business actions needs to be performed in the bean associated with the target page based on (post)constructor or
<f:viewParam>.