Skip to content

Commit 41921c4

Browse files
committed
1 parent e43d331 commit 41921c4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/main/java/org/primefaces/renderkit/OutcomeTargetRenderer.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,29 @@ protected boolean isIncludeViewParams(UIOutcomeTarget outcomeTarget, NavigationC
143143
return outcomeTarget.isIncludeViewParams() || navCase.isIncludeViewParams();
144144
}
145145

146+
protected String prependContextPathNecessary(FacesContext facesContext, String path) {
147+
if (path.length() > 0 && path.charAt(0) == '/') {
148+
String contextPath = facesContext.getExternalContext().getRequestContextPath();
149+
if (contextPath == null) {
150+
return path;
151+
}
152+
else if (contextPath.length() == 1 && contextPath.charAt(0) == '/') {
153+
// If the context path is root, it is not necessary to append it, otherwise an extra '/' will be set.
154+
return path;
155+
}
156+
else {
157+
return contextPath + path;
158+
}
159+
}
160+
return path;
161+
}
162+
146163
protected String getTargetURL(FacesContext context, UIOutcomeTarget outcomeTarget) {
147164
String url;
165+
148166
String href = outcomeTarget.getHref();
149-
150167
if (href != null) {
151-
url = href;
168+
url = prependContextPathNecessary(context, href);
152169
}
153170
else {
154171
NavigationCase navCase = findNavigationCase(context, outcomeTarget);

0 commit comments

Comments
 (0)