myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r267179 - in /myfaces/share/trunk/src/java/org/apache/myfaces/renderkit: RendererUtils.java html/HtmlRadioRendererBase.java html/HtmlRendererUtils.java
Date Fri, 02 Sep 2005 10:31:53 GMT
Author: mbr
Date: Fri Sep  2 03:31:45 2005
New Revision: 267179

URL: http://svn.apache.org/viewcvs?rev=267179&view=rev
Log:
fix for MYFACES-72,
required flag was not working for selectOneRadio.
Initialy it was only a problem with HtmlRadioRendererBase.decode()
called HtmlRendererUtils.decodeUIInput instead of 
HtmlRendererUtils.decodeUISelectOne.

But to make MYFACES-465 work an empty string couldnĀ“t be used.
It is be possible that an identifier of a select item is equal 
to an empty string. A special constant (RendererUtils.NOTHING) 
is used instead.

Modified:
    myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/RendererUtils.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

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/RendererUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/RendererUtils.java?rev=267179&r1=267178&r2=267179&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/RendererUtils.java (original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/renderkit/RendererUtils.java Fri Sep 
2 03:31:45 2005
@@ -16,6 +16,7 @@
 package org.apache.myfaces.renderkit;
 
 import java.io.IOException;
+import java.io.Serializable;
 import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -62,6 +63,7 @@
 
     public static final String SELECT_ITEM_LIST_ATTR = RendererUtils.class.getName() + ".LIST";
     public static final String EMPTY_STRING = new String();
+    public static final Object NOTHING = new Serializable() {};
 
     public static String getPathToComponent(UIComponent component)
     {
@@ -708,6 +710,10 @@
     {
         if (submittedValue!=null && !(submittedValue instanceof String))
         {
+            if(RendererUtils.NOTHING.equals(submittedValue))
+            {
+                return null;
+            }
             throw new IllegalArgumentException("Submitted value of type String for component
: "+
                     getPathToComponent(output)+"expected");
         }

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=267179&r1=267178&r2=267179&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 03:31:45 2005
@@ -87,14 +87,14 @@
         List selectItemList = RendererUtils.getSelectItemList(selectOne);
         converter = HtmlRendererUtils.findUIOutputConverterFailSafe(facesContext, selectOne);
 
-        String currentValueStr = RendererUtils.getStringValue(facesContext, selectOne);
+        Object currentValue = RendererUtils.getObjectValue(selectOne);
 
         for (Iterator it = selectItemList.iterator(); it.hasNext(); )
         {
             SelectItem selectItem = (SelectItem)it.next();
             
             renderGroupOrItemRadio(facesContext, selectOne, 
-            		selectItem, currentValueStr,
+            		selectItem, currentValue,
             		converter, pageDirectionLayout);
             
             if (pageDirectionLayout) writer.endElement(HTML.TR_ELEM);
@@ -129,7 +129,7 @@
     
     protected void renderGroupOrItemRadio(FacesContext facesContext,
     		UIComponent uiComponent, SelectItem selectItem,
-    		String currentValueStr,
+    		Object currentValue,
     		Converter converter, boolean pageDirectionLayout) throws IOException{
     	
     	ResponseWriter writer = facesContext.getResponseWriter();
@@ -163,7 +163,7 @@
         	SelectItem[] selectItems = group.getSelectItems();
         	
         	for (int i=0; i<selectItems.length; i++) {
-        		renderGroupOrItemRadio(facesContext, selectOne, selectItems[i], currentValueStr,
converter, pageDirectionLayout);
+        		renderGroupOrItemRadio(facesContext, selectOne, selectItems[i], currentValue, converter,
pageDirectionLayout);
         	}
         	
         	writer.endElement(HTML.TD_ELEM);
@@ -185,7 +185,7 @@
         String itemStrValue = RendererUtils.getConvertedStringValue(facesContext, selectOne,
converter, selectItem.getValue());
         boolean itemDisabled = selectItem.isDisabled();
         
-        boolean itemChecked = currentValueStr.equals(itemStrValue);
+        boolean itemChecked = itemStrValue.equals(currentValue);
         
         renderRadio(facesContext, selectOne, itemStrValue, selectItem
                 .getLabel(), itemDisabled, itemChecked, false);
@@ -263,7 +263,7 @@
         RendererUtils.checkParamValidity(facesContext, uiComponent, null);
         if (uiComponent instanceof UIInput)
         {
-            HtmlRendererUtils.decodeUIInput(facesContext, uiComponent);
+            HtmlRendererUtils.decodeUISelectOne(facesContext, uiComponent);
         }
     }
 

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=267179&r1=267178&r2=267179&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 03:31:45 2005
@@ -201,7 +201,7 @@
                     .get(clientId));
         } else {
             //see reason for this action at decodeUISelectMany
-            ((EditableValueHolder) component).setSubmittedValue( RendererUtils.EMPTY_STRING
);
+            ((EditableValueHolder) component).setSubmittedValue( RendererUtils.NOTHING );
         }
     }
 
@@ -317,8 +317,15 @@
             {
                 lookup = uiSelectOne.getValue();
             }
-            String lookupString = RendererUtils.getConvertedStringValue(facesContext, uiComponent,
converter, lookup);
-            lookupSet = Collections.singleton(lookupString);
+            if(RendererUtils.NOTHING.equals(lookup))
+            {
+                lookupSet = Collections.EMPTY_SET;
+            }
+            else
+            {
+                String lookupString = RendererUtils.getConvertedStringValue(facesContext,
uiComponent, converter, lookup);
+                lookupSet = Collections.singleton(lookupString);
+            }
         }
         return lookupSet;
     }



Mime
View raw message