myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r812591 - in /myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit: JSFAttr.java html/HtmlCheckboxRendererBase.java html/HtmlRendererUtils.java
Date Tue, 08 Sep 2009 17:29:55 GMT
Author: lu4242
Date: Tue Sep  8 17:29:54 2009
New Revision: 812591

URL: http://svn.apache.org/viewvc?rev=812591&view=rev
Log:
MYFACES-2283 Apply selected/unselected css class to h:selectManyCheckbox (Thanks to Jakob
Korherr for this patch)

Modified:
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java
    myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java?rev=812591&r1=812590&r2=812591&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/JSFAttr.java
Tue Sep  8 17:29:54 2009
@@ -66,6 +66,8 @@
     String BORDER_ATTR                 = "border";
     String DISABLED_CLASS_ATTR         = "disabledClass";
     String ENABLED_CLASS_ATTR          = "enabledClass";
+    String SELECTED_CLASS_ATTR         = "selectedClass";
+    String UNSELECTED_CLASS_ATTR       = "unselectedClass";
 
     // Common Command Attributes
     /**@deprecated */

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java?rev=812591&r1=812590&r2=812591&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlCheckboxRendererBase.java
Tue Sep  8 17:29:54 2009
@@ -209,7 +209,7 @@
             boolean componentDisabled = isDisabled(facesContext, selectMany);
             boolean itemDisabled = (componentDisabled || disabled);
 
-            HtmlRendererUtils.renderLabel(writer, selectMany, itemId, selectItem, itemDisabled);
+            HtmlRendererUtils.renderLabel(writer, selectMany, itemId, selectItem, itemDisabled,
checked);
 
             writer.endElement(HTML.TD_ELEM);
             if (pageDirectionLayout)

Modified: myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?rev=812591&r1=812590&r2=812591&view=diff
==============================================================================
--- myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
(original)
+++ myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
Tue Sep  8 17:29:54 2009
@@ -1495,6 +1495,74 @@
     }
 
     /**
+     * Renders a label HTML element
+     */
+    public static void renderLabel(ResponseWriter writer,
+                                   UIComponent component,
+                                   String forClientId,
+                                   SelectItem item,
+                                   boolean disabled,
+                                   boolean selected) throws IOException
+    {
+            writer.startElement(HTML.LABEL_ELEM, component);
+            writer.writeAttribute(HTML.FOR_ATTR, forClientId, null);
+
+            String labelClass = null;
+
+            if (disabled)
+            {
+                labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
+            }
+            else
+            {
+                labelClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ENABLED_CLASS_ATTR);
+            }
+            
+            String labelSelectedClass = null;
+            
+            if(selected)
+            {
+                labelSelectedClass = (String) component.getAttributes().get(JSFAttr.SELECTED_CLASS_ATTR);
   
+            }
+            else 
+            {
+                labelSelectedClass = (String) component.getAttributes().get(JSFAttr.UNSELECTED_CLASS_ATTR);
+            }
+            
+            if(labelSelectedClass != null) 
+            {
+                if(labelClass == null) 
+                {
+                    labelClass = labelSelectedClass;
+                }
+                else
+                {
+                    labelClass = labelClass + " " + labelSelectedClass;
+                }
+            }
+            
+            if (labelClass != null)
+            {
+                writer.writeAttribute("class", labelClass, "labelClass");
+            }
+
+            if ((item.getLabel() != null) && (item.getLabel().length() > 0))
+            {
+                writer.write(HTML.NBSP_ENTITY);
+                if(item.isEscape())
+                {
+                    writer.writeText(item.getLabel(), null);
+                }
+                else
+                {
+                    writer.write(item.getLabel());
+                }
+            }
+
+            writer.endElement(HTML.LABEL_ELEM);
+    }
+
+    /**
      * Render the javascript function that is called on a click on a commandLink
      * to clear the hidden inputs. This is necessary because on a browser back,
      * each hidden input still has it's old value (browser cache!) and therefore



Mime
View raw message