Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for derivePhysicalViewId broken in #5120 #5217

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022, 2023 Contributors to Eclipse Foundation.
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -438,9 +439,20 @@ protected String derivePhysicalViewId(FacesContext ctx, String requestViewId, bo
HttpServletMapping mapping = getFacesMapping(ctx);
String physicalViewId;

if (mapping.getMappingMatch() == EXACT || mapping.getMappingMatch() == EXTENSION) {
// Exact mapping, e.g. /foo or Prefix mapping, e.g. /foo.xhtml
if (mapping.getMappingMatch() == EXTENSION) {
// Suffix mapping, e.g. /foo.xhtml
physicalViewId = convertViewId(ctx, requestViewId);
} else if (mapping.getMappingMatch() == EXACT) {
if (requestViewId.equals(mapping.getPattern())) {
// Fuzzy logic: if request equals the view ID we're asking for
// this is a call from MultiViewHandler.createView. In that case instead
// of /foo we want /foo.xhtml.
return convertViewId(ctx, requestViewId);
}

// Exact mapping, e.g. /foo
// We're likely called here by derive*ViewId, which wants /foo
physicalViewId = requestViewId;
} else {
// Prefix mapping, e.g. /faces/foo.xhtml
physicalViewId = normalizeRequestURI(requestViewId, mapping.getPattern().replace("/*", ""));
Expand Down Expand Up @@ -756,4 +768,4 @@ private void appendOrReplaceExtension(String viewId, String extension, int lengt
}
}

}
}