Re: ADF, PrettyFaces and a persistent query param

Splash Forums PrettyFaces Users ADF, PrettyFaces and a persistent query param Re: ADF, PrettyFaces and a persistent query param

#21572

clemmonsm
Participant

Hey guys,

I have had a chance to implement a custom rewrite processor. Unfortunately, it appears that when the processor runs, ADF has already re-initialized the “_adf.ctrl-state” query param value, so I no longer have access to the prior value which I need to append to the URL. I am perplexed because I expected the query param value to not yet be altered by ADF since the redirect has not taken place. Any enlightenment you can provide would be much appreciated. Thanks!

Here is my config and code…

<!-- For URLs containing ".jspx", utilize processor -->
<rewrite match=".*(.jspx)+.*" processor="siteUtils.PrettyFacesAdfProcessor" redirect="301" />

package siteUtils;

import com.ocpsoft.pretty.faces.config.rewrite.RewriteRule;
import com.ocpsoft.pretty.faces.rewrite.Processor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class PrettyFacesAdfProcessor implements Processor {

public String processInbound(final HttpServletRequest request, final HttpServletResponse response, final RewriteRule rewrite, final String url) {
// do nothing
return url;
}

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

if (request.getParameterValues("_adf.ctrl-state") != null && !url.contains("_adf.ctrl-state")) {
// param exists and is not assigned to url
// Unfortunately, it appears the query value in the request has been altered at this point in the lifecycle

// append _adf.ctrl-state key/value to query string
String newUrl = url + "?_adf.ctrl-state=" + request.getParameterValues("_adf.ctrl-state")[0];

return newUrl;
}

return url;
}
}