logger.debug("encodeActionURL fromURL=[{0}]", url);
String currentFacesViewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
BridgeActionURL bridgeActionURL = bridgeURLFactory.getBridgeActionURL(url, currentFacesViewId, this);
// Determine the target of the specified URL, which could be a Faces-View or a
// Non-Faces-View.
String contextRelativeViewPath = bridgeActionURL.getContextRelativePath();
List<String> defaultSuffixes = bridgeConfig.getConfiguredSuffixes();
List<ConfiguredServletMapping> facesServletMappings = bridgeConfig.getConfiguredFacesServletMappings();
FacesView targetFacesView = new FacesViewImpl(contextRelativeViewPath, defaultSuffixes, facesServletMappings);
// If the specified URL starts with "portlet:", then
if (bridgeActionURL.isPortletScheme()) {
// If the "_jsfBridgeViewId" URL parameter is equal to "_jsfBridgeCurrentView" then the
// URL is self-referencing and the "_jsfBridgeViewId" parameter muse be removed from the
// URL.
String facesViewIdParameter = bridgeActionURL.getParameter(Bridge.FACES_VIEW_ID_PARAMETER);
if (Bridge.FACES_USE_CURRENT_VIEW_PARAMETER.equals(facesViewIdParameter)) {
bridgeActionURL.setSelfReferencing(true);
bridgeActionURL.removeParameter(Bridge.FACES_VIEW_ID_PARAMETER);
}
// If the "_jsfBridgeViewPath" URL parameter is equal to "_jsfBridgeCurrentView" then
// the URL is self-referencing and the "_jsfBridgeViewPath" parameter muse be removed
// from the URL.
String facesViewPathParameter = bridgeActionURL.getParameter(Bridge.FACES_VIEW_PATH_PARAMETER);
if (Bridge.FACES_USE_CURRENT_VIEW_PARAMETER.equals(facesViewPathParameter)) {
bridgeActionURL.setSelfReferencing(true);
bridgeActionURL.removeParameter(Bridge.FACES_VIEW_PATH_PARAMETER);
}
}
// Otherwise, the specified URL must be for a path-encoded URL (either a Faces-View or
// Non-Faces-View)
else {
// If the specified URL has a "javax.portlet.faces.DirectLink" parameter with a value of
// "false", then remove it from the map of parameters as required by the Bridge Spec.
String directLinkParam = bridgeActionURL.getParameter(Bridge.DIRECT_LINK);
if (BooleanHelper.isFalseToken(directLinkParam)) {
bridgeActionURL.removeParameter(Bridge.DIRECT_LINK);
}
if (!bridgeActionURL.isAbsolute() && !targetFacesView.isExtensionMapped() &&
!targetFacesView.isPathMapped() && !url.startsWith(StringPool.POUND)) {
bridgeActionURL.setParameter(Bridge.NONFACES_TARGET_PATH_PARAMETER, contextRelativeViewPath);
}
}
return bridgeActionURL;