You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/01/12 04:09:50 UTC
svn commit: r898162 - in /myfaces/core/trunk:
api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
Author: lu4242
Date: Tue Jan 12 03:09:50 2010
New Revision: 898162
URL: http://svn.apache.org/viewvc?rev=898162&view=rev
Log:
MYFACES-2464 Find a way to do not use ELExpressions on jsf.js for getProjectStage (Thanks to Jakob Korherr for this patch)
Modified:
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js?rev=898162&r1=898161&r2=898162&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js Tue Jan 12 03:09:50 2010
@@ -378,10 +378,38 @@
/**
* @return the project stage also emitted by the server:
* it cannot be cached and must be delivered over the server
- *
+ * The value for it comes from the request parameter of the jsf.js script called "stage".
*/
myfaces._impl.core._jsfImpl.prototype.getProjectStage = function() {
- return "#{facesContext.application.projectStage}";
+ /* run through all script tags and try to find the one that includes jsf.js */
+ var scriptTags = document.getElementsByTagName("script");
+ for (var i = 0; i < scriptTags.length; i++)
+ {
+ if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1)
+ {
+ /* try to extract stage=XXX */
+ var result = scriptTags[i].src.match(/stage=([^&;]*)/);
+ if (result)
+ {
+ /* we found stage=XXX */
+ /* return only valid values of ProjectStage */
+ if (result[1] == "Production"
+ || result[1] == "Development"
+ || result[1] == "SystemTest"
+ || result[1] == "UnitTest")
+ {
+ return result[1];
+ }
+ }
+ else
+ {
+ /* we found the script, but there was no stage parameter --> Production */
+ return "Production";
+ }
+ }
+ }
+ /* we could not find anything valid --> return the default value */
+ return "Production";
};
/**
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java?rev=898162&r1=898161&r2=898162&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/resource/ResourceImpl.java Tue Jan 12 03:09:50 2010
@@ -30,6 +30,7 @@
import javax.el.ELContext;
import javax.el.ValueExpression;
+import javax.faces.application.ProjectStage;
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
import javax.faces.context.FacesContext;
@@ -83,8 +84,7 @@
{
String contentType = getContentType();
- return ("text/css".equals(contentType) ||
- ( "jsf.js".equals(getResourceName()) && "javax.faces".equals(getLibraryName())));
+ return ("text/css".equals(contentType));
}
private class ValueExpressionFilterInputStream extends InputStream
@@ -196,6 +196,7 @@
path = (mapping == null) ? path : mapping + path;
}
+ FacesContext facesContext = FacesContext.getCurrentInstance();
String metadata = null;
boolean useAmp = false;
if (getLibraryName() != null)
@@ -203,11 +204,17 @@
metadata = "?ln=" + getLibraryName();
path = path + metadata;
useAmp = true;
+
+ if (!facesContext.isProjectStage(ProjectStage.Production)
+ && "jsf.js".equals(getResourceName())
+ && "javax.faces".equals(getLibraryName()))
+ {
+ // append &stage=?? for all ProjectStages except Production
+ path = path + "&stage=" + facesContext.getApplication().getProjectStage().toString();
+ }
}
- return FacesContext.getCurrentInstance().getApplication().
- getViewHandler().getResourceURL(
- FacesContext.getCurrentInstance(), path);
+ return facesContext.getApplication().getViewHandler().getResourceURL(facesContext, path);
}
@Override