I've got a dropdown on my index.xhtml JSF front page. The associated code/commandButton looks like this:
<h:selectOneMenu id="nodes" value="#{MyBacking.chosenNode}">
<f:selectItems value="#{MyBacking.nodes}" />
</h:selectOneMenu>
<a4j:commandButton value="Retrieve" styleClass="ctrlBtn"
id="retrieveBtn" style="margin-bottom: 2px;"
onclick="#{rich:component('nodeLoadWait')}.show()" # modal
action="#{MyBacking.redirect}"
image="/img/btnRetrieve26.png" />
action was set to 'hello' previously, and in my faces-context.xml:
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>hello</from-outcome>
<to-view-id>/nodeMgmt.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
When action was set to 'hello', clicking the retrieve button worked OK in that faces would handle the nav and MyBacking.setChosenNode method would assign all the necessary data, so that the content of nodeMgmt.xhtml would be displayed fully populated.
However, if the initial activity caused by the user clicking retrieve times out, the web page would hang even though the bean detects the time out, and I'd like to redirect the user to a 'timed out' page.
In order to handle the backing bean returning a timedout message (the error detection for which is already present when 'inside' the app), I thought rather than using the faces-context.xml file, I would handle it internally.
I found FacesContext.getCurrentInstance().getExternalContext().redirect but the JSF 1.2 javadoc does not feature this. Perhaps it's because it's not featured? It redirects though which is confusing. Why no documentation on this method?
Nonetheless, it redirects me to the page, but renders without taking into account the data instantiated by the bean during the initial request. The bean is in request scope currently. The relevant code in the bean is
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("nodeMgmt.jsf");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Is using a backend java call the best way to do this kind of redirection?
If not, is it best to use faces-context.xml? If so, how?
While we're here - can anyone direct me to a good reading resource for FacesContext.getCurrentInstance().getExternalContext() usage which has decent examples about how to do simple navigation with data cos I'm having trouble locating one.
Cheers