Question

I've configured an Apache Httpd Server with mod_weblogic.c in front of Weblogic 11g runnig JSF 2 Web App.

An address like:

http://hostname/partToBeTrimmed/myContextPath/restOfPath.xhtml

is trasformed by Httpd server in:

http://hostname/myContextPath/restOfPath.xhtml

The application respond and show the page, but all the link generated by JSF inside the page are:

/myContextPath/restOfPath.xhtml
/myContextPath/resource1.some
/myContextPath/resource2.some

So on the next call the address is wrong, because httpd server do not respond witout the "partToBeTrimmed" prepending the rest of the path.

How I can force JSF to add a "partToBeTrimmed" to all link (from command, and from resource, etc) generated?

Thanks for help.

Was it helpful?

Solution

Resolved with:

<view-handler>my.package.view.PathTrimViewHandler</view-handler>

In faces-config.xml

and the class:

public class PathTrimViewHandler extends ViewHandlerWrapper {

private final ViewHandler wrappped;

public PathTrimViewHandler(ViewHandler wrappped) {
    super();
    this.wrappped = wrappped;
}

@Override
public ViewHandler getWrapped() {
    return wrappped;
}

@Override
public String getActionURL(FacesContext context, String viewId) {
    String url = super.getActionURL(context, viewId);
    return addRootContextPath(context, url);
}

@Override
public String getResourceURL(FacesContext context, String path) {
    String url = super.getResourceURL(context, path);
    return addRootContextPath(context, url);
}

private String addRootContextPath(FacesContext context, String url) {

    return "/partToBeTrimmed"+url;
}

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top