MYFACES-3226 move to Location aware exceptions
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAwareFacesException.java b/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAwareFacesException.java
index 3d45559..2fdfabc 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAwareFacesException.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/LocationAwareFacesException.java
@@ -47,6 +47,12 @@
super(cause);
this.location = location;
}
+
+ public LocationAwareFacesException(Throwable cause, UIComponent component)
+ {
+ super(cause);
+ this.location = (Location) component.getAttributes().get(UIComponent.VIEW_LOCATION_KEY);
+ }
public LocationAwareFacesException(String message)
{
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java b/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java
index 6b3afc9..3ab3a26 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java
@@ -21,7 +21,6 @@
import java.io.IOException;
import java.util.List;
import java.util.Map;
-import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.context.FacesContext;
@@ -37,6 +36,7 @@
import org.apache.myfaces.renderkit.html.base.HtmlRenderer;
import org.apache.myfaces.renderkit.html.util.HtmlRendererUtils;
import org.apache.myfaces.renderkit.html.util.ResourceUtils;
+import org.apache.myfaces.view.facelets.LocationAwareFacesException;
/**
*
@@ -74,8 +74,8 @@
if (elementName == null)
{
- throw new FacesException("jsf:element with clientId"
- + component.getClientId(facesContext) + " requires 'elementName' passthrough attribute");
+ throw new LocationAwareFacesException("jsf:element with clientId"
+ + component.getClientId(facesContext) + " requires 'elementName' passthrough attribute", component);
}
JsfElement jsfElement = (JsfElement) component;
Map<String, List<ClientBehavior>> behaviors = jsfElement.getClientBehaviors();
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java b/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
index 57d2277..9863a4d 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
@@ -1085,7 +1085,7 @@
}
catch (IOException e)
{
- throw new FacesException(e);
+ throw new LocationAwareFacesException(e, this);
}
finally
{
@@ -1125,10 +1125,10 @@
}
catch (Exception e)
{
- throw new FacesException(e);
+ throw new LocationAwareFacesException(e, this);
}
}
-
+
// Now Look throught facets on this UIComponent
if (this.getFacetCount() > 0)
{
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java
index a101300..db46d22 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java
@@ -44,6 +44,7 @@
import javax.faces.view.facelets.ValidatorConfig;
import javax.faces.view.facelets.ValidatorHandler;
import org.apache.myfaces.config.MyfacesConfig;
+import org.apache.myfaces.view.facelets.LocationAwareFacesException;
import org.apache.myfaces.view.facelets.tag.composite.CompositeComponentResourceTagHandler;
import org.apache.myfaces.view.facelets.tag.composite.CompositeResouceWrapper;
@@ -439,12 +440,14 @@
}
else
{
- throw new FacesException("Error Instantiating: " + handlerType.getName(), t);
+ throw new LocationAwareFacesException("Error Instantiating: " + handlerType.getName(), t,
+ cfg.getTag().getLocation());
}
}
catch (Exception e)
{
- throw new FacesException("Error Instantiating: " + handlerType.getName(), e);
+ throw new LocationAwareFacesException("Error Instantiating: " + handlerType.getName(), e,
+ cfg.getTag().getLocation());
}
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java
index f12c750..22cf07c 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/ClientBehaviorAttachedObjectTargetImpl.java
@@ -24,12 +24,12 @@
import java.util.List;
import javax.el.ValueExpression;
-import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
import org.apache.myfaces.util.lang.ArrayUtils;
import org.apache.myfaces.util.lang.StringUtils;
+import org.apache.myfaces.view.facelets.LocationAwareFacesException;
/**
* @author Leonardo Uribe (latest modification by $Author$)
@@ -81,8 +81,9 @@
}
else
{
- throw new FacesException("Component with clientId " + innerComponent.getClientId(facesContext)
- + "should be instance of ClientBehaviorHolder");
+ throw new LocationAwareFacesException("Component with clientId "
+ + innerComponent.getClientId(facesContext)
+ + "should be instance of ClientBehaviorHolder", innerComponent);
}
}
}
@@ -110,8 +111,9 @@
}
else
{
- throw new FacesException("Component with clientId "+ innerComponent.getClientId(facesContext)
- + "should be instance of ClientBehaviorHolder");
+ throw new LocationAwareFacesException("Component with clientId "
+ + innerComponent.getClientId(facesContext)
+ + "should be instance of ClientBehaviorHolder", innerComponent);
}
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java
index a599d69..bd4c8f6 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/tag/composite/CreateDynamicCompositeComponentListener.java
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.util.Map;
-import javax.faces.FacesException;
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -35,6 +34,7 @@
import org.apache.myfaces.view.facelets.FaceletFactory;
import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage;
import org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguageBase;
+import org.apache.myfaces.view.facelets.LocationAwareFacesException;
import org.apache.myfaces.view.facelets.compiler.RefreshDynamicComponentListener;
import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
@@ -178,12 +178,11 @@
}
catch (IOException e)
{
- throw new FacesException(e);
+ throw new LocationAwareFacesException(e, component);
}
finally
{
- facesContext.getAttributes().remove(
- FaceletViewDeclarationLanguage.REFRESHING_TRANSIENT_BUILD);
+ facesContext.getAttributes().remove(FaceletViewDeclarationLanguage.REFRESHING_TRANSIENT_BUILD);
}
}
@@ -225,8 +224,7 @@
}
else if (values[0] instanceof Integer)
{
- RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(
- context.getExternalContext());
+ RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(context.getExternalContext());
taglibURI = runtimeConfig.getNamespaceById().get((Integer)values[0]);
}
else if (values[0] instanceof Object[])
diff --git a/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java b/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
index a9e5ea9..fdd2124 100644
--- a/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
+++ b/impl/src/main/java/org/apache/myfaces/webapp/AbstractFacesInitializer.java
@@ -218,7 +218,8 @@
}
// print out a very prominent log message if the project stage is != Production
- if (!facesContext.isProjectStage(ProjectStage.Production))
+ if (!facesContext.isProjectStage(ProjectStage.Production)
+ && !facesContext.isProjectStage(ProjectStage.UnitTest))
{
ProjectStage projectStage = facesContext.getApplication().getProjectStage();
StringBuilder message = new StringBuilder("\n\n");