You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ba...@apache.org on 2005/09/19 09:33:17 UTC

svn commit: r290080 - /myfaces/impl/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java

Author: baranda
Date: Mon Sep 19 00:33:13 2005
New Revision: 290080

URL: http://svn.apache.org/viewcvs?rev=290080&view=rev
Log:
Fixes MYFACES-575. Thanks to Marcus Schiesser

Modified:
    myfaces/impl/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java

Modified: myfaces/impl/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/impl/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java?rev=290080&r1=290079&r2=290080&view=diff
==============================================================================
--- myfaces/impl/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java (original)
+++ myfaces/impl/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlLabelRenderer.java Mon Sep 19 00:33:13 2005
@@ -55,41 +55,46 @@
         HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.LABEL_PASSTHROUGH_ATTRIBUTES);
 
         String forAttr = getFor(uiComponent);
-        if (forAttr == null)
-        {
-            throw new NullPointerException("Attribute 'for' of label component with id " + uiComponent.getClientId(facesContext));
-        }
 
-        UIComponent forComponent = uiComponent.findComponent(forAttr);
-        if (forComponent == null)
-        {
-            if (log.isWarnEnabled())
-            {
-                log.warn("Unable to find component '" + forAttr + "' (calling findComponent on component '" + uiComponent.getClientId(facesContext) + "')");
-            }
-            if (forAttr.length() > 0 && forAttr.charAt(0) == UINamingContainer.SEPARATOR_CHAR)
+        if (forAttr != null)
             {
-                //absolute id path
-                writer.writeAttribute(HTML.FOR_ATTR, forAttr.substring(1), JSFAttr.FOR_ATTR);
-            }
-            else
+            UIComponent forComponent = uiComponent.findComponent(forAttr);
+            if (forComponent == null)
             {
-                //relative id path, we assume a component on the same level as the label component
-                String labelClientId = uiComponent.getClientId(facesContext);
-                int colon = labelClientId.lastIndexOf(UINamingContainer.SEPARATOR_CHAR);
-                if (colon == -1)
+                if (log.isWarnEnabled())
                 {
-                    writer.writeAttribute(HTML.FOR_ATTR, forAttr, JSFAttr.FOR_ATTR);
+                    log.warn("Unable to find component '" + forAttr + "' (calling findComponent on component '" + uiComponent.getClientId(facesContext) + "')");
+                }
+                if (forAttr.length() > 0 && forAttr.charAt(0) == UINamingContainer.SEPARATOR_CHAR)
+                {
+                    //absolute id path
+                    writer.writeAttribute(HTML.FOR_ATTR, forAttr.substring(1), JSFAttr.FOR_ATTR);
                 }
                 else
                 {
-                    writer.writeAttribute(HTML.FOR_ATTR, labelClientId.substring(0, colon + 1) + forAttr, JSFAttr.FOR_ATTR);
+                    //relative id path, we assume a component on the same level as the label component
+                    String labelClientId = uiComponent.getClientId(facesContext);
+                    int colon = labelClientId.lastIndexOf(UINamingContainer.SEPARATOR_CHAR);
+                    if (colon == -1)
+                    {
+                        writer.writeAttribute(HTML.FOR_ATTR, forAttr, JSFAttr.FOR_ATTR);
+                    }
+                    else
+                    {
+                        writer.writeAttribute(HTML.FOR_ATTR, labelClientId.substring(0, colon + 1) + forAttr, JSFAttr.FOR_ATTR);
+                    }
                 }
             }
-        }
-        else
+            else
+            {
+                writer.writeAttribute(HTML.FOR_ATTR, forComponent.getClientId(facesContext), JSFAttr.FOR_ATTR);
+            }
+        } 
+        else 
         {
-            writer.writeAttribute(HTML.FOR_ATTR, forComponent.getClientId(facesContext), JSFAttr.FOR_ATTR);
+            if (log.isWarnEnabled()) {
+                log.warn("Attribute 'for' of label component with id " + uiComponent.getClientId(facesContext)+" is not defined");
+            }
         }