Dynamic Page Navigation
Hi,
I have a situation where a certain page can be called from any part of the application. But once the user has completed his/her task on this page it must return to the calling page.
I don't want to define navigation rules to return to all parts of the application from this page. I have tried using response.sendRedirect(), but that causes an exception. Any way to get around this problem?
Thanks.
[430 byte] By [
umarmalika] at [2007-11-27 4:09:44]

# 1
You can define navigation rules without source page:
<navigation-rule>
<description>Menu navigation. Valid from all pages.</description>
<from-view-id>*</from-view-id>
<navigation-case>
<description>Go to Page1</description>
<from-outcome>go_page1</from-outcome>
<to-view-id>/Page1.jsp</to-view-id>
</navigation-case>
<navigation-case>
<description>Go to Page2</description>
<from-outcome>go_page2</from-outcome>
<to-view-id>/Page2.jsp</to-view-id>
</navigation-case>
</navigation-rule>
You can omit the line
<from-view-id>*</from-view-id>
# 3
You can get the View-ID AFTER RESTORE_VIEW and save it in a Bean in request scope.
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot viewRoot = context.getViewRoot();
String viewId = viewRoot.getViewId();
BEFORE RESTORE_VIEW FacesContext.getViewRoot() returns null!
If you want to store the address before RESTORE_VIEW, you have to use the ExternalContext:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
String address = request.getPathInfo();
Message was edited by:
Ingmar