You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by rakesh_bhalke <ra...@gmail.com> on 2011/12/07 06:43:57 UTC

URL Rewirting

Hi,

Click JSImport and CSImport by default appends the context to the js and css
files. This causes issues in URL rewirting as follows

Lets say i have 1 application to be deployed for 3 customers. Each on these
is deployed on seperate tomcat instances. Hence the URL for each application
will look like this

http://internalip:8080/TestApp/
http://internalip.com:8081/TestApp/
http://internalip.com:8082/TestApp/

Now if my http server is front ending these tomcats then my URL rewrite will
be as 
http://myapp.com/TestApp1/  pointing to http://internalip:8080/TestApp/
http://myapp.com/TestApp2/  pointing to http://internalip:8081/TestApp/
http://myapp.com/TestApp3/  pointing to http://internalip:8082/TestApp/

Now if we see the html generated by click, it is 
/TestApp1/css/style.css  
/TestApp1/clickclick/jquery/jquery-1.3.2.js

 because of which URL rewriting fails.

Our analysis is as follows

Following code from JsImport which add context path in js file url.

public void setSrc(String src) {
        if (src != null) {
            if (src.charAt(0) == '/') {
                Context context = getContext();
                String contextPath = context.getRequest().getContextPath();

                // Guard against adding duplicate context path
                if (!src.startsWith(contextPath + '/')) {
                    HtmlStringBuffer buffer =
                        new HtmlStringBuffer(contextPath.length() +
src.length());

                    // Append the context path
                    buffer.append(contextPath);
                    buffer.append(src);
                    src = buffer.toString();
                }
            }
        }
        setAttribute("src", src);
    }

Our suggestion is to not append the context and to create a relative path
for JS and CSS imports.



--
View this message in context: http://click.1134972.n2.nabble.com/URL-Rewirting-tp7069479p7069479.html
Sent from the click-development mailing list archive at Nabble.com.