Re: Query parameters showing in URL on initial page access

Splash Forums PrettyFaces Users Query parameters showing in URL on initial page access Re: Query parameters showing in URL on initial page access



Alright, I think I figured this out, so here it is for other ADF developers…

Much like the solution I penned for outbound links, found at the URL below, I got this working by appending the params back onto the URL, this time for inbounds:

PrettyFaces Processor and Rewrite rules for ADF developers

The trick was twofold:

1) Only process on the inbound call when the “_adf.ctrl-state” token is present. This ensures we are reapplying the correct “_afrLoop” token value, which can change between the first and second inbound calls.

2) Add the ADF params back to the URL in the same order they were in before removing the unwanted params. ADF must be expecting a defined order – when I added the params back with “_adf.ctrl-state” as the first param, the page would not load correctly.

Here is the rewrite rule:

<!-- inbound rewrite rule to process inbound urls that have query parameters -->
<rewrite outbound="false" match=".*(^/$|/about-drees/|/finance/|/build-on-your-lot/|/new-homes/|/request-info/|/career/)+.*(?)" processor="siteUtils.PrettyFacesAdfProcessor" redirect="301" />

Here is the inbound processor code:

public String processInbound(final HttpServletRequest request, final HttpServletResponse response, final RewriteRule rewrite, final String url) {

// we have a URL with query params

if (request.getParameterValues("_adf.ctrl-state") != null && url.contains("_adf.ctrl-state")) {
// we have access to _adf.ctrl-state & query string includes _adf.ctrl-state, so we can begin rewriting the inbound
String newUrl = url.replaceAll("\?(.*)", ""); // remove query string
String params = "";

// add other required ADF params back, in order
if (request.getParameterValues("_afrWindowId") != null) {
params = "?_afrWindowId=" + request.getParameterValues("_afrWindowId")[0];

if (request.getParameterValues("_afrLoop") != null) {
params = params + (params.length() == 0 ? "?_afrLoop=" : "&_afrLoop=") + request.getParameterValues("_afrLoop")[0];

if (request.getParameterValues("_afrWindowMode") != null) {
params = params + (params.length() == 0 ? "?_afrWindowMode=" : "&_afrWindowMode=") + request.getParameterValues("_afrWindowMode")[0];

newUrl = newUrl + params + (params.length() == 0 ? "?_adf.ctrl-state=" : "&_adf.ctrl-state=") + request.getParameterValues("_adf.ctrl-state")[0]; // add _adf.ctrl-state back

return newUrl;

return url;

Thanks for the help guys!