myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject svn commit: r267201 - in /myfaces/share/trunk/src/java/org/apache/myfaces: renderkit/html/ taglib/html/
Date Fri, 02 Sep 2005 13:47:50 GMT
Author: oros
Date: Fri Sep  2 06:47:41 2005
New Revision: 267201

URL: http://svn.apache.org/viewcvs?rev=267201&view=rev
Log:
MYFACES-480: enabledClass/disabledClass for HtmlSelect*

Modified:
    myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererBase.java
    myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java
    myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java
    myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectListboxTagBase.java
    myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectMenuTagBase.java

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererBase.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererBase.java?rev=267201&r1=267200&r2=267201&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererBase.java
(original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlCheckboxRendererBase.java
Fri Sep  2 06:47:41 2005
@@ -201,8 +201,22 @@
 
         boolean disabled = selectItem.isDisabled();
         
-        renderCheckbox(facesContext, selectMany, itemStrValue, selectItem
+
+        String labelClass = null;
+        boolean componentDisabled = isDisabled(facesContext, selectMany);
+
+        if (componentDisabled || disabled) {
+            labelClass = (String) selectMany.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
+        } else {
+            labelClass = (String) selectMany.getAttributes().get(JSFAttr.ENABLED_CLASS_ATTR);
+        }
+        if (labelClass != null) {
+            writer.writeAttribute("class", labelClass, "labelClass");
+        }
+
+            renderCheckbox(facesContext, selectMany, itemStrValue, selectItem
                 .getLabel(), disabled, checked, false);
+
         writer.endElement(HTML.LABEL_ELEM);
         writer.endElement(HTML.TD_ELEM);
         if (pageDirectionLayout)

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java?rev=267201&r1=267200&r2=267201&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java
(original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRadioRendererBase.java
Fri Sep  2 06:47:41 2005
@@ -92,11 +92,11 @@
         for (Iterator it = selectItemList.iterator(); it.hasNext(); )
         {
             SelectItem selectItem = (SelectItem)it.next();
-            
-            renderGroupOrItemRadio(facesContext, selectOne, 
+
+            renderGroupOrItemRadio(facesContext, selectOne,
             		selectItem, currentValue,
             		converter, pageDirectionLayout);
-            
+
             if (pageDirectionLayout) writer.endElement(HTML.TR_ELEM);
         }
 
@@ -126,56 +126,56 @@
          return (String)selectOne.getAttributes().get(JSFAttr.STYLE_CLASS_ATTR);
      }
 
-    
+
     protected void renderGroupOrItemRadio(FacesContext facesContext,
     		UIComponent uiComponent, SelectItem selectItem,
     		Object currentValue,
     		Converter converter, boolean pageDirectionLayout) throws IOException{
-    	
+
     	ResponseWriter writer = facesContext.getResponseWriter();
-    	
+
     	boolean isSelectItemGroup = (selectItem instanceof SelectItemGroup);
-    	
+
     	// TODO : Check here for getSubmittedValue. Look at RendererUtils.getValue
     	// this is useless object creation
-//    	Object itemValue = selectItem.getValue(); 
+//    	Object itemValue = selectItem.getValue();
 
     	UISelectOne selectOne = (UISelectOne)uiComponent;
-    	
+
         if (isSelectItemGroup) {
         	if (pageDirectionLayout)
                 writer.startElement(HTML.TR_ELEM, selectOne);
-        	
+
         	writer.startElement(HTML.TD_ELEM, selectOne);
         	writer.write(selectItem.getLabel());
         	writer.endElement(HTML.TD_ELEM);
-        	
+
         	if (pageDirectionLayout) {
 	        	writer.endElement(HTML.TR_ELEM);
 	        	writer.startElement(HTML.TR_ELEM, selectOne);
         	}
         	writer.startElement(HTML.TD_ELEM, selectOne);
-        	
+
         	writer.startElement(HTML.TABLE_ELEM, selectOne);
         	writer.writeAttribute(HTML.BORDER_ATTR, "0", null);
 
         	SelectItemGroup group = (SelectItemGroup) selectItem;
         	SelectItem[] selectItems = group.getSelectItems();
-        	
+
         	for (int i=0; i<selectItems.length; i++) {
         		renderGroupOrItemRadio(facesContext, selectOne, selectItems[i], currentValue, converter,
pageDirectionLayout);
         	}
-        	
+
         	writer.endElement(HTML.TD_ELEM);
         	writer.endElement(HTML.TR_ELEM);
         	writer.endElement(HTML.TABLE_ELEM);
         	writer.endElement(HTML.TD_ELEM);
-        	
+
         	if (pageDirectionLayout)
                 writer.endElement(HTML.TR_ELEM);
-        	
+
         } else {
-        
+
         writer.write("\t\t");
         if (pageDirectionLayout)
             writer.startElement(HTML.TR_ELEM, selectOne);
@@ -184,9 +184,21 @@
 
         String itemStrValue = RendererUtils.getConvertedStringValue(facesContext, selectOne,
converter, selectItem.getValue());
         boolean itemDisabled = selectItem.isDisabled();
-        
+
         boolean itemChecked = itemStrValue.equals(currentValue);
-        
+
+        String labelClass = null;
+        boolean componentDisabled = isDisabled(facesContext, selectOne);
+
+        if (componentDisabled || itemDisabled) {
+            labelClass = (String) selectOne.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
+        } else {
+            labelClass = (String) selectOne.getAttributes().get(JSFAttr.ENABLED_CLASS_ATTR);
+        }
+        if (labelClass != null) {
+            writer.writeAttribute("class", labelClass, "labelClass");
+        }
+
         renderRadio(facesContext, selectOne, itemStrValue, selectItem
                 .getLabel(), itemDisabled, itemChecked, false);
         writer.endElement(HTML.LABEL_ELEM);
@@ -211,7 +223,7 @@
         writer.startElement(HTML.INPUT_ELEM, uiComponent);
         writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_RADIO, null);
         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
-        
+
         if (disabled) {
             writer.writeAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR, null);
         }

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java?rev=267201&r1=267200&r2=267201&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java
(original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/html/HtmlRendererUtils.java
Fri Sep  2 06:47:41 2005
@@ -35,6 +35,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.config.MyfacesConfig;
 import org.apache.myfaces.renderkit.RendererUtils;
+import org.apache.myfaces.renderkit.JSFAttr;
 import org.apache.myfaces.renderkit.html.util.DummyFormUtils;
 import org.apache.myfaces.renderkit.html.util.HTMLEncoder;
 import org.apache.myfaces.renderkit.html.util.JavascriptUtils;
@@ -406,10 +407,24 @@
                             HTML.SELECTED_ATTR, null);
                 }
 
-                if (selectItem.isDisabled()) {
+                boolean disabled = selectItem.isDisabled();
+                if (disabled) {
                     writer.writeAttribute(HTML.DISABLED_ATTR,
                             HTML.DISABLED_ATTR, null);
                 }
+
+                String labelClass = null;
+                boolean componentDisabled = isTrue(component.getAttributes().get("disabled"));
+
+                if (componentDisabled || disabled) {
+                    labelClass = (String) component.getAttributes().get(JSFAttr.DISABLED_CLASS_ATTR);
+                } else {
+                    labelClass = (String) component.getAttributes().get(JSFAttr.ENABLED_CLASS_ATTR);
+                }
+                if (labelClass != null) {
+                    writer.writeAttribute("class", labelClass, "labelClass");
+                }
+
 
                 writer.writeText(selectItem.getLabel(), null);
 

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectListboxTagBase.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectListboxTagBase.java?rev=267201&r1=267200&r2=267201&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectListboxTagBase.java
(original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectListboxTagBase.java
Fri Sep  2 06:47:41 2005
@@ -16,6 +16,7 @@
 package org.apache.myfaces.taglib.html;
 
 import org.apache.myfaces.renderkit.html.HTML;
+import org.apache.myfaces.renderkit.JSFAttr;
 
 import javax.faces.component.UIComponent;
 
@@ -57,6 +58,10 @@
     // UISelectMany attributes
     //selectedValues cannot be set here, is set in JSP-parsing
 
+    // HTMLSelectManyAttributes attributes
+    private String _disabledClass;
+    private String _enabledClass;
+
     public void release() {
         super.release();
         _datafld=null;
@@ -70,6 +75,8 @@
         _onselect=null;
         _size=null;
         _tabindex=null;
+        _disabledClass = null;
+        _enabledClass = null;
     }
 
     protected void setProperties(UIComponent component)
@@ -87,6 +94,9 @@
         setStringProperty(component, HTML.ONSELECT_ATTR, _onselect);
         setIntegerProperty(component, HTML.SIZE_ATTR, _size);
         setStringProperty(component, HTML.TABINDEX_ATTR, _tabindex);
+
+        setStringProperty(component, JSFAttr.DISABLED_CLASS_ATTR, _disabledClass);
+        setStringProperty(component, JSFAttr.ENABLED_CLASS_ATTR, _enabledClass);
    }
 
     public void setDatafld(String datafld)
@@ -144,4 +154,13 @@
         _tabindex = tabindex;
     }
 
+    public void setDisabledClass(String disabledClass)
+    {
+        _disabledClass = disabledClass;
+    }
+
+    public void setEnabledClass(String enabledClass)
+    {
+        _enabledClass = enabledClass;
+    }
 }

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectMenuTagBase.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectMenuTagBase.java?rev=267201&r1=267200&r2=267201&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectMenuTagBase.java
(original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/taglib/html/HtmlSelectMenuTagBase.java
Fri Sep  2 06:47:41 2005
@@ -16,6 +16,7 @@
 package org.apache.myfaces.taglib.html;
 
 import org.apache.myfaces.renderkit.html.HTML;
+import org.apache.myfaces.renderkit.JSFAttr;
 
 import javax.faces.component.UIComponent;
 
@@ -59,6 +60,11 @@
     //HtmlSelectManyMenu Attributes
     private String _border;
 
+    // HTMLSelectManyAttributes attributes
+    private String _disabledClass;
+    private String _enabledClass;
+
+
     public void release() {
         super.release();
         _datafld=null;
@@ -72,6 +78,8 @@
         _onselect=null;
         _tabindex=null;
         _border=null;
+        _disabledClass=null;
+        _enabledClass=null;
     }
 
     protected void setProperties(UIComponent component)
@@ -88,6 +96,8 @@
         setStringProperty(component, HTML.ONFOCUS_ATTR, _onfocus);
         setStringProperty(component, HTML.ONSELECT_ATTR, _onselect);
         setStringProperty(component, HTML.TABINDEX_ATTR, _tabindex);
+        setStringProperty(component, JSFAttr.DISABLED_CLASS_ATTR, _disabledClass);
+        setStringProperty(component, JSFAttr.ENABLED_CLASS_ATTR, _enabledClass);
 
         setIntegerProperty(component, HTML.BORDER_ATTR, _border);
    }
@@ -147,4 +157,13 @@
         _tabindex = tabindex;
     }
 
+    public void setDisabledClass(String disabledClass)
+    {
+        _disabledClass = disabledClass;
+    }
+
+    public void setEnabledClass(String enabledClass)
+    {
+        _enabledClass = enabledClass;
+    }
 }



Mime
View raw message