I'm stuck in a navigation case problem similar to this one.
In a few words, I'm trying to redirect navigation from one page to another, using an ajax rendered h:commandLink
.
Here's the backing bean
@ManagedBean
public class StartBean {
public void search(){
FacesContext
.getCurrentInstance()
.getExternalContext()
.getFlash()
.put("result", "hooray!")
;
}
public String showResult(){
return "result?faces-redirect=true";
}
}
and the starting page
<h:body>
<h:form prependId="false">
<h:commandButton value="Click" action="#{startBean.search}">
<f:ajax execute="@this" render="@form"/>
</h:commandButton>
<br/>
<h:commandLink
action="#{startBean.showResult()}"
rendered="#{flash.result != null}"
value="#{flash.result}"
/>
</h:form>
</h:body>
whereas result
page is just showing a message. Both pages are on web module context root.
It happens that the h:commandLink
is correctly displayed after ajax submit, but clicking on it causes a page refresh. It doesn't redirect towards the result
page, as expected.
After it, if page is reloaded (F5), result
page is shown. It seems to be a rendering cycle matter.
Any suggestion?
Thanks in advance.