1/07/2012

Can only redirect during ACTION_PHASE: Redirect and ICEfaces

If you are using ICEFaces 2 and you wonder why you can´t use this to perform a redirect in your backing bean action method:

FacesContext.getCurrentInstance().getExternalContext().redirect("http://www.somewhere.com");

and you are getting the following Exception:


java.io.UnsupportedEncodingException: 
Can only redirect during ACTION_PHASE at org.portletfaces.bridge.container.liferay.PortletContainerLiferayImpl.redirect(PortletContainerLiferayImpl.java:233) 
at org.portletfaces.bridge.context.ExternalContextImpl.redirect(ExternalContextImpl.java:412) 
at com.brightsky.bean.WorkBasketModelBean.navigateToPage(WorkBasketModelBean.java:39) 
at com.brightsky.bean.WorkBasketBackingBean.navigateToPage(WorkBasketBackingBean.java:65) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)




Then you might want to update your portlet faces bridge to version 2.0.1. 
They added support for redirecting outside the Action Phase.
You can get it here: http://www.portletfaces.org/portletfaces-bridge/downloads


If you like this post it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.