}
}
public void redirect(String url) throws IOException {
BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
PortletResponse portletResponse = bridgeContext.getPortletResponse();
if (portletResponse instanceof ActionResponse) {
ActionResponse actionResponse = (ActionResponse) portletResponse;
actionResponse.sendRedirect(url);
}
else if (portletResponse instanceof ResourceResponse) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (isJSF2PartialRequest(facesContext)) {
redirectJSF2PartialResponse(facesContext, (ResourceResponse) portletResponse, url);
}
else {
throw new UnsupportedEncodingException(
"Can only redirect during RESOURCE_PHASE if a JSF partial/Ajax request has been triggered");
}
}
else {
throw new UnsupportedEncodingException("Unable to redirect during " +
bridgeContext.getPortletRequestPhase());
}
}