-
1. Re: Error handler page does not work
kenfinni Apr 15, 2013 8:57 AM (in response to mbasovni)Martin,
Is @PostConstruct being used with CDI?
I think that @PostConstruct is too early in the lifecycle of the object for Portlet Bridge to be active and hence able to handle the exception.
Ken
-
2. Re: Error handler page does not work
mbasovni Apr 16, 2013 4:30 PM (in response to kenfinni)I tried to use it as with CDI as with EJB...
It should be only example. My real problem is that I want to ban entrance for unlogged users to my portlet and I use PortletFilter. If user is unlogged it thorws my custom UserUnloggedException which extends PortletException. But this does not work. I only wanted to show my problem on easier example. Any idea how to solve it? I want to show special xhtml for unlogged users and it seems to me good idea to use PortletFilter...
public class UserLoggedFilter implements javax.portlet.filter.RenderFilter { @Override public void init(FilterConfig filterConfig) throws PortletException { } @Override public void destroy() { } @Override public void doFilter(RenderRequest request, RenderResponse response, FilterChain chain) throws IOException, PortletException { chain.doFilter(request, response); if (request.getRemoteUser() == null) { throw new UnloggedUserException(); } } }
-
3. Re: Error handler page does not work
kenfinni Apr 17, 2013 9:16 AM (in response to mbasovni)Martin,
The problem with a PortletFilter is that it executes before Portlet Bridge is involved in the request, so there's no way for Portlet Bridge exception handling to deal with an exception from a portlet filter.
For Portlet Bridge exception handling to capture the exception and display an appropriate page, the exception needs to be thrown within the JSF lifecycle.
The best way I can think of to accomplish this is with a PhaseListener that is executed during the beforePhase() of RESTORE_VIEW. Within the phase listener method you can then check for the user credentials and throw your exception if they aren't present. Then Portlet Bridge would receive the exception from the JSF lifecycle
-
4. Re: Error handler page does not work
mbasovni Apr 17, 2013 2:54 PM (in response to kenfinni)Thank you, for your answer!