You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/10/25 16:50:08 UTC

svn commit: r1027152 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageFactory.java tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java

Author: lofwyr
Date: Mon Oct 25 14:50:08 2010
New Revision: 1027152

URL: http://svn.apache.org/viewvc?rev=1027152&view=rev
Log:
Add error message in case of development mode, to make it easier to find the error.

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageFactory.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageFactory.java?rev=1027152&r1=1027151&r2=1027152&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageFactory.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageFactory.java Mon Oct 25 14:50:08 2010
@@ -17,6 +17,8 @@ package org.apache.myfaces.tobago.util;
  * limitations under the License.
  */
 
+import org.apache.myfaces.tobago.application.ProjectStage;
+import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 
 import javax.faces.application.FacesMessage;
@@ -104,4 +106,14 @@ public final class MessageFactory {
     }
     return facesMessages;
   }
+
+  /**
+   * Creates a message and adds it to the faces context, if the project stage is development.
+   */
+  public static void addDevelopmentMessage(FacesContext facesContext, String message) {
+    if (TobagoConfig.getInstance(FacesContext.getCurrentInstance()).getProjectStage() == ProjectStage.Development) {
+      facesContext.addMessage(null, new FacesMessage(message));
+    }
+  }
+
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java?rev=1027152&r1=1027151&r2=1027152&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java Mon Oct 25 14:50:08 2010
@@ -24,6 +24,7 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
 import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.MessageFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -318,8 +319,11 @@ public class RenderUtils {
         } else if (value instanceof SelectItem) {
           list.add((SelectItem) value);
         } else {
-          throw new IllegalArgumentException("TYPE ERROR: value NOT instanceof SelectItem. type="
-              + value.getClass().getName());
+          final String message 
+              = "TYPE ERROR: value NOT instanceof SelectItem. type="
+              + value.getClass().getName() + " value=" + value;
+          LOG.error(message);
+          MessageFactory.addDevelopmentMessage(FacesContext.getCurrentInstance(), message);
         }
       } else if (kid instanceof UISelectItems) {
         Object value = ((UISelectItems) kid).getValue();
@@ -352,9 +356,11 @@ public class RenderUtils {
             }
           }
         } else {
-          throw new IllegalArgumentException("TYPE ERROR: value NOT instanceof "
-              + "SelectItem, SelectItem[], Collection, Map. type="
-              + value.getClass().getName());
+          final String message
+              = "TYPE ERROR: value NOT instanceof SelectItem, SelectItem[], Collection, Map. type="
+              + value.getClass().getName() + " value=" + value;
+          LOG.error(message);
+          MessageFactory.addDevelopmentMessage(FacesContext.getCurrentInstance(), message);
         }
       }
     }