Reply To: wrong post url

Splash Forums Rewrite Users wrong post url Reply To: wrong post url

#25146

I wasn’t able to run your sample app due to missing dependencies, but I think I can tell you what is going wrong.

Actually your custom view handler is incorrect. It looks like you are trying to extends the existing default view handler of Mojarra by creating a subclass. If you do it this way, the RewriteViewHander will be completely ignored which is why you are getting problems.

As there may be multiple view handlers in a single application, you have to use some kind of wrapper pattern instead. Something like this:


public class ReverseProxyViewHandler extends ViewHandler {

	private ViewHandler parent;

	public ReverseProxyViewHandler(ViewHandler parent) {
	    this.parent = parent;
	}

	@Override
	public Locale calculateLocale(FacesContext context) {
	    return parent.calculateLocale(context);
	}

	@Override
	public String calculateRenderKitId(FacesContext context) {
	    return parent.calculateRenderKitId(context);
	}

        /* more */
}

This way you will get a “chain” of view handlers. So if you want to do some custom stuff, you will typically add some code to one of the methods, but keep calling the parent view handler to do the real stuff.

Here is another example of how to create a custom view handler that delegates calls to the parent (default) view handler.

http://www.gregbugaj.com/?p=164