You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2015/11/19 02:34:23 UTC

svn commit: r1715084 - /myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java

Author: lu4242
Date: Thu Nov 19 01:34:23 2015
New Revision: 1715084

URL: http://svn.apache.org/viewvc?rev=1715084&view=rev
Log:
MYFACES-3957 Disabled h:commandLink results in rendering of a span with onclick (thanks to Thomas Andraschko for provide this patch)

Modified:
    myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java

Modified: myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java?rev=1715084&r1=1715083&r2=1715084&view=diff
==============================================================================
--- myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java (original)
+++ myfaces/core/branches/2.1.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java Thu Nov 19 01:34:23 2015
@@ -237,7 +237,9 @@ public abstract class HtmlLinkRendererBa
         // h:commandLink can be rendered outside a form, but with warning (jsf 2.0 TCK)
         FormInfo formInfo = findNestingForm(component, facesContext);
         
-        if (HtmlRendererUtils.isDisabled(component) || formInfo == null)
+        boolean disabled = HtmlRendererUtils.isDisabled(component);
+        
+        if (disabled || formInfo == null)
         {
             writer.startElement(HTML.SPAN_ELEM, component);
             if (component instanceof ClientBehaviorHolder && JavascriptUtils.isJavascriptAllowed(
@@ -257,28 +259,62 @@ public abstract class HtmlLinkRendererBa
                 {
                     commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(component);
                 }
-                if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                
+                // only render onclick if != disabled
+                if (!disabled)
                 {
-                    CommonPropertyUtils.renderEventProperties(writer, 
-                            commonPropertiesMarked, component);
-                    CommonPropertyUtils.renderFocusBlurEventProperties(writer,
-                            commonPropertiesMarked, component);
+                    if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
+                    {
+                        CommonPropertyUtils.renderEventProperties(writer, 
+                                commonPropertiesMarked, component);
+                        CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                                commonPropertiesMarked, component);
+                    }
+                    else
+                    {
+                        if (isCommonEventsOptimizationEnabled(facesContext))
+                        {
+                            Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(component);
+                            CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
+                                    commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                            CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                        }
+                        else
+                        {
+                            HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, 
+                                    behaviors);
+                            HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                    facesContext, writer, component, behaviors);
+                        }
+                    }
                 }
                 else
                 {
-                    if (isCommonEventsOptimizationEnabled(facesContext))
+                    if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
                     {
-                        Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(component);
-                        CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
-                                commonPropertiesMarked, commonEventsMarked, component, behaviors);
-                        CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                            facesContext, writer, commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                        CommonPropertyUtils.renderEventPropertiesWithoutOnclick(writer, 
+                                commonPropertiesMarked, component);
+                        CommonPropertyUtils.renderFocusBlurEventProperties(writer,
+                                commonPropertiesMarked, component);
                     }
                     else
                     {
-                        HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, component, behaviors);
-                        HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
-                                facesContext, writer, component, behaviors);
+                        if (isCommonEventsOptimizationEnabled(facesContext))
+                        {
+                            Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(component);
+                            CommonEventUtils.renderBehaviorizedEventHandlersWithoutOnclick(facesContext, writer, 
+                                    commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                            CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                facesContext, writer, commonPropertiesMarked, commonEventsMarked, component, behaviors);
+                        }
+                        else
+                        {
+                            HtmlRendererUtils.renderBehaviorizedEventHandlersWithoutOnclick(facesContext, writer,
+                                    component, behaviors);
+                            HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchangeAndOnselect(
+                                    facesContext, writer, component, behaviors);
+                        }
                     }
                 }
                 if (isCommonPropertiesOptimizationEnabled(facesContext))