ResourceServlet not workinh with org.ajax4jsf.VIEW_HANDLERS

UI Components for JSF
Post Reply
ahoehma
Posts: 8
Joined: 11 Nov 2009, 10:30
Location: Leipzig
Contact:

28 Jan 2010, 16:48

In a customer project a have a special requirement : the application must run behind a reverse-proxy. For that all absolute url's must be convert to relative urls with a custom Viewhandler.

web.xml example:

First the view handler for richfaces ...

Code: Select all

<context-param>
    <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
    <param-value>
      com.sun.facelets.FaceletViewHandler,com.foobar.ReverseProxyViewHandler
    </param-value>
</context-param>
later in the web.xml I put the servlet-mapping for primefaces ...

Code: Select all

<servlet>
    <servlet-name>Resource Servlet</servlet-name>
    <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
<servlet-mapping>
    <servlet-name>Resource Servlet</servlet-name>
    <url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>
If I run the application behind the reverseproxy, all richfaces/myfaces resources are relative urls, but all prime-faces resource-servlet-url's are absolute :shock:

Example:

Code: Select all


<script src="../../../sas-user-0.1.1-SNAPSHOT-B20100128/a4j/g/3_3_2.CR1/org/ajax4jsf/framework.pack.js.jsf" ....
            ^^^^^^^^^^
<script type="text/javascript" src="/sas-user-0.1.1-SNAPSHOT-B20100128/primefaces_resource/1.0.0.RC/primefaces/core/core.js">
                                 ^^^^
Any idea?

Regards
Andreas
-=[http://www.ahoehma.de]=-

ahoehma
Posts: 8
Joined: 11 Nov 2009, 10:30
Location: Leipzig
Contact:

28 Jan 2010, 17:42

I found the place to fix :D

Code: Select all

org.primefaces.resource.ResourceUtils ...
public static String getResourceURL(FacesContext facesContext, String resource) {
  String contextPath = facesContext.getExternalContext().getRequestContextPath();
  return contextPath + RESOURCE_PATTERN + VERSION_INFO + resource;
}
This version would be more "compatible" with jsf ...

Code: Select all

public static String getResourceURL(final FacesContext facesContext, final String resource) {
    final String theURL = RESOURCE_PATTERN + VERSION_INFO + resource;
    return facesContext.getApplication().getViewHandler().getResourceURL(facesContext, theURL);
}
Regards
Andreas

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

28 Jan 2010, 18:05

Can you create a ticket in our issue tracker for this as an enhancement, I agree we should use getResourceURL.


cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

03 Feb 2010, 11:54

Thank you Andreas

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 56 guests