[
https://issues.jboss.org/browse/SEAMFACES-103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12591037#comment-12591037
]
Brian Leathem commented on SEAMFACES-103:
-----------------------------------------
In case the linked to page disappears:
JSF 2 Internals - Efficient way of Redirecting to a Page
There are certain cases where you are needed to redirect to a different page
than requested by user e.g. if user has requested a secure page for which
he/she is not authorized, your application will have to redirect to login page
or some other page. I have created a utility method to redirect to a page. You
can call anywhere but for example given above, you can call it a beforePhase
method of RestoreViewPhaseListener. Here is the method code:
public static void redirect(String viewId) {
execute(FacesContext.getCurrentInstance(), viewId);
}
private static void execute(FacesContext facesContext, String viewId)
throws FacesException {
UIViewRoot viewRoot = null;
ViewDeclarationLanguage vdl = facesContext.getApplication()
.getViewHandler()
.getViewDeclarationLanguage(facesContext, viewId);
if (vdl != null) {
// If we have one, get the ViewMetadata...
ViewMetadata metadata = vdl.getViewMetadata(facesContext,
viewId);
if (metadata != null) { // perhaps it's not supported
// and use it to create the ViewRoot. This will have, at
// most
// the UIViewRoot and its metadata facet.
viewRoot = metadata.createMetadataView(facesContext);
}
}
facesContext.setViewRoot(viewRoot);
facesContext.renderResponse();
assert (null != viewRoot);
}
> Create an api for doing a redirect to another view
> --------------------------------------------------
>
> Key: SEAMFACES-103
> URL: https://issues.jboss.org/browse/SEAMFACES-103
> Project: Seam Faces
> Issue Type: Feature Request
> Reporter: Brian Leathem
> Fix For: 3.1
>
>
> See:
> http://www.dzone.com/links/r/efficient_way_to_redirect_to_a_page_in_jsf_2.html
> <mojavelinux> surely it must be simpler than that with the JSF 2 API, but atm
> I can't remember whether we included a simpler api
> <mojavelinux> he's doing specifically an internal forward
> <mojavelinux> but obviously having one that does a regular redirect would be
> ideal too
> <mojavelinux> btw, this would be from an arbitrary point in an action or
> action listener
> <mojavelinux> as opposed to using navigation rules
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues