You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2012/02/06 19:06:31 UTC

svn commit: r1241099 - in /myfaces/trinidad/trunk/trinidad-api/src/main: java/org/apache/myfaces/trinidad/component/UIXComponent.java xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts

Author: arobinson74
Date: Mon Feb  6 18:06:31 2012
New Revision: 1241099

URL: http://svn.apache.org/viewvc?rev=1241099&view=rev
Log:
TRINIDAD-2203 - Improve error message

Modified:
    myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
    myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=1241099&r1=1241098&r2=1241099&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java Mon Feb  6 18:06:31 2012
@@ -1033,8 +1033,9 @@ abstract public class UIXComponent exten
       if (!(contextChange instanceof VisitDebugContextChange) ||
           ((VisitDebugContextChange)contextChange)._component != this)
       {
-        String errorMessage = _LOG.getMessage("INVALID_CONTEXT_CHANGE_FOUND");
-        throw new IllegalStateException(errorMessage);
+        throw new IllegalStateException(_getInvalidContextChangeMessage(
+                                          VisitDebugContextChange.class,
+                                          contextChange));
       }
 
       _inVisitingContext = false;
@@ -1076,8 +1077,9 @@ abstract public class UIXComponent exten
       if (!(contextChange instanceof VisitChildrenDebugContextChange) ||
           ((VisitChildrenDebugContextChange)contextChange)._component != this)
       {
-        String errorMessage = _LOG.getMessage("INVALID_CONTEXT_CHANGE_FOUND");
-        throw new IllegalStateException(errorMessage);
+        throw new IllegalStateException(_getInvalidContextChangeMessage(
+                                          VisitChildrenDebugContextChange.class,
+                                          contextChange));
       }
 
       _inChildrenVisitingContext = false;
@@ -1439,6 +1441,17 @@ abstract public class UIXComponent exten
     return UIPanel.class == componentClass;
   }
 
+  private String _getInvalidContextChangeMessage(
+    Class<? extends ComponentContextChange> expectedClass,
+    ComponentContextChange                  foundChange)
+  {
+    String type = expectedClass.getName();
+    String id = (getParent() == null) ? getId() : getClientId();
+
+    return _LOG.getMessage("INVALID_CONTEXT_CHANGE_FOUND",
+      new Object[] { type, id, foundChange });
+  }
+
   private static class VisitDebugContextChange
     extends ComponentContextChange
   {
@@ -1477,6 +1490,15 @@ abstract public class UIXComponent exten
       _component._tearDownEncodingCaller = null;
     }
 
+    @Override
+    public String toString()
+    {
+      return String.format("VisitDebugContextChange(component: %s, id: %s)",
+               _component,
+               _component == null ? null :
+               _component.getParent() == null ? _component.getId() : _component.getClientId());
+    }
+
     private final UIXComponent _component;
     private boolean _inVisitingContext;
     private boolean _inEncodingContext;
@@ -1524,6 +1546,15 @@ abstract public class UIXComponent exten
       _component._tearDownChildrenVisitingCaller = null;
     }
 
+    @Override
+    public String toString()
+    {
+      return String.format("VisitChildrenDebugContextChange(component: %s, id: %s)",
+               _component,
+               _component == null ? null :
+               _component.getParent() == null ? _component.getId() : _component.getClientId());
+    }
+
     private final UIXComponent _component;
     private boolean _inChildrenVisitingContext;
     private boolean _inChildrenEncodingContext;

Modified: myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts?rev=1241099&r1=1241098&r2=1241099&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts (original)
+++ myfaces/trinidad/trunk/trinidad-api/src/main/xrts/org/apache/myfaces/trinidad/resource/LoggerBundle.xrts Mon Feb  6 18:06:31 2012
@@ -514,6 +514,6 @@
 <resource key="COMPONENT_NOT_IN_VISITING_CONTEXT">tearDownVisitingContext called on a component that is not in context. Client ID: {0}. Originally called by {1}.</resource>
 
 <!-- INVALID_CONTEXT_CHANGE_FOUND -->
-<resource key="INVALID_CONTEXT_CHANGE_FOUND">An unexpected component context change was found. This is due to components not correctly maintaining the context change stack.</resource>
+<resource key="INVALID_CONTEXT_CHANGE_FOUND">An unexpected component context change was found. This is due to components not correctly maintaining the context change stack. Expected change of type {0} for component {1} but received change {2}.</resource>
 
 </resources>