Repository: tapestry-5
Updated Branches:
  refs/heads/master 12cd14d5d -> 18ea65471


TAP5-2509, TAP5-2500: log a warning in development mode instead of throwing an 
exception if a Label is used with a Field that does not return its clientId (in 
time)


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/18ea6547
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/18ea6547
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/18ea6547

Branch: refs/heads/master
Commit: 18ea654718212d4f65d98fb7a106bfbbecc34d47
Parents: 12cd14d
Author: Jochen Kemnade <[email protected]>
Authored: Thu Nov 5 12:56:03 2015 +0100
Committer: Jochen Kemnade <[email protected]>
Committed: Thu Nov 5 12:56:03 2015 +0100

----------------------------------------------------------------------
 .../apache/tapestry5/corelib/components/Label.java  | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/18ea6547/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
----------------------------------------------------------------------
diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
index 44a32b9..815200a 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Label.java
@@ -19,7 +19,9 @@ import org.apache.tapestry5.annotations.Parameter;
 import org.apache.tapestry5.annotations.SupportsInformalParameters;
 import org.apache.tapestry5.dom.Element;
 import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.services.javascript.JavaScriptSupport;
 
 /**
  * Generates a &lt;label&gt; element for a particular field. It writes the CSS 
class "control-label".
@@ -47,6 +49,13 @@ public class Label
     @Inject
     private ComponentResources resources;
 
+    @Inject
+    private JavaScriptSupport javaScriptSupport;
+
+    @Inject
+    @Symbol(SymbolConstants.PRODUCTION_MODE)
+    private boolean productionMode;
+
     /**
      * If true, then the body of the label element (in the template) is 
ignored. This is used when a designer places a
      * value inside the &lt;label&gt; element for WYSIWYG purposes, but it 
should be replaced with a different
@@ -80,9 +89,12 @@ public class Label
     {
         String fieldId = field.getClientId();
 
-        if (fieldId == null)
+        if (!productionMode && fieldId == null)
         {
-            throw new IllegalStateException("The field has returned a null 
client-side ID");
+            // TAP5-2500
+            String warningText = "The Label component " + 
resources.getCompleteId()
+              + " is linked to a Field that failed to return a clientId. The 
'for' attibute will not be rendered.";
+            
javaScriptSupport.require("t5/core/console").invoke("warn").with(warningText);
         }
 
         labelElement.forceAttributes("for", fieldId);

Reply via email to