You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ss...@apache.org on 2005/08/29 19:04:14 UTC
svn commit: r264168 -
/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/AddResource.java
Author: ssilvert
Date: Mon Aug 29 10:04:10 2005
New Revision: 264168
URL: http://svn.apache.org/viewcvs?rev=264168&view=rev
Log:
Applied patch for MYFACES-453. Thanks to Thomas Heute of JBoss.
Modified:
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/AddResource.java
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/AddResource.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/AddResource.java?rev=264168&r1=264167&r2=264168&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/AddResource.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/util/AddResource.java Mon Aug 29 10:04:10 2005
@@ -132,21 +132,20 @@
* Note : set context to null if you want the path after the application context path.
*/
public static String getResourceMappedPath(Class componentClass, String resourceFileName, FacesContext context){
- HttpServletRequest request = null;
- if( context != null )
- request = (HttpServletRequest)context.getExternalContext().getRequest();
-
+ String contextPath = null;
+ if( context != null ){
+ contextPath = context.getExternalContext().getRequestContextPath();
+ }
+
return getResourceMappedPath(
getComponentName(componentClass),
resourceFileName,
- request);
+ contextPath);
}
- protected static String getResourceMappedPath(String componentName, String resourceFileName, HttpServletRequest request){
- String contextPath = "";
- if( request != null )
- contextPath = request.getContextPath();
- return contextPath+RESOURCE_VIRTUAL_PATH+"/"+componentName+'/'+getCacheKey()+'/'+resourceFileName;
+ private static String getResourceMappedPath(String componentName, String resourceFileName, String contextPath){
+ String returnString = RESOURCE_VIRTUAL_PATH+"/"+componentName+'/'+getCacheKey()+'/'+resourceFileName;
+ return (contextPath == null) ? returnString : contextPath + returnString;
}
private static long getCacheKey(){
@@ -430,25 +429,34 @@
return inlineText.equals(toCompare.inlineText);
}
+ /**
+ * @Deprecated
+ */
public String getString(HttpServletRequest request){
- switch (type) {
- case TYPE_JS:
- return "<script "
- +"src=\""+getResourceMappedPath(componentName, resourceFileName, request)+"\" "
- +(deferJS ? "defer=\"true\" " : "")
- +"type=\"text/javascript\""
- +">"
- +"</script>\n";
- case TYPE_CSS:
- return "<link rel=\"stylesheet\" "
- +"href=\""+getResourceMappedPath(componentName, resourceFileName, request)+"\" "
- +"type=\"text/css\"/>\n";
- case TYPE_CSS_INLINE:
- return "<style type=\"text/css\">"+inlineText+"</style>\n";
- default:
- log.warn("Unknown type:"+type);
- return "<link href=\""+"\"/>\n";
- }
+ return getString(request.getContextPath());
}
+
+ public String getString(String contextPath){
+ switch (type) {
+ case TYPE_JS:
+ return "<script "
+ +"src=\""+getResourceMappedPath(componentName, resourceFileName, contextPath)+"\" "
+ +(deferJS ? "defer=\"true\" " : "")
+ +"type=\"text/javascript\""
+ +">"
+ +"</script>\n";
+ case TYPE_CSS:
+ return "<link rel=\"stylesheet\" "
+ +"href=\""+getResourceMappedPath(componentName, resourceFileName, contextPath)+"\" "
+ +"type=\"text/css\"/>\n";
+ case TYPE_CSS_INLINE:
+ return "<style type=\"text/css\">"+inlineText+"</style>\n";
+ default:
+ log.warn("Unknown type:"+type);
+ return "<link href=\""+"\"/>\n";
+ }
+ }
+
+
}
}