-
1. Re: redirect to current page after a NotLoggedInException
norman Apr 2, 2008 1:42 AM (in response to mbakkali)How about #{facesContext.viewRoot.viewId}?
-
2. Re: redirect to current page after a NotLoggedInException
mbakkali Apr 2, 2008 2:31 AM (in response to mbakkali)Nope. Didn't work.
In pages.xml, I tried to also add this at the topic at the login-view-id attribute. It didn't even resolve EL.
(I saw the same #{facesContext...} in the browser
for a brief instant).Also I had to add
/
before EL because Seam complained about
the fact that a view-id must start with/
.Maybe there is another way to do this?
-
3. Re: redirect to current page after a NotLoggedInException
norman Apr 2, 2008 4:55 AM (in response to mbakkali)Ah. I see. The reason that expression doesn't work is that we are in the ExceptionFilter, which operates outside of the faces lifecycle and uses the Mock contexts, not the real ones. The mock contexts don't remember the viewId you were accessing. If you look at RedirectHandler.java, you can see the logic we use to reconstruct the viewId from the the servlet path. It's not terribly robust, but it should work for you. Here's what I tested:
@Name("viewId") @Scope(ScopeType.STATELESS) public class ViewId { public String getCurrentValue() { String servletPath = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getServletPath(); return servletPath.substring(0, servletPath.lastIndexOf('.')) + Pages.getSuffix(); } }
That works with:
<redirect view-id="#{viewId.currentValue}">
There should be a way to do this without crazy hacks. If you open a JIRA, I'll make sure we provide a better solution.
-
4. Re: redirect to current page after a NotLoggedInException
mbakkali Apr 2, 2008 9:30 AM (in response to mbakkali)That sounds like a good hack!
However the only thing is that the method getCurrentValue()
resolves to the page I was trying to access (instead of the current page I was at).I guess you tested this calling a method with a
@Restrict("#{identity.loggedIn}")
annotation.In my case, I am clicking on a link to a restricted page (not method/class) so the current page is not the same I guess from Seam's stand point.
I guess now the goal is to find out how to get the
current page
.