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 2010/06/05 06:58:31 UTC
svn commit: r951649 -
/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java
Author: lu4242
Date: Sat Jun 5 04:58:31 2010
New Revision: 951649
URL: http://svn.apache.org/viewvc?rev=951649&view=rev
Log:
TOMAHAWK-1517 t:selectOneRow does not handle integers
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java?rev=951649&r1=951648&r2=951649&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/selectOneRow/SelectOneRowRenderer.java Sat Jun 5 04:58:31 2010
@@ -18,18 +18,20 @@
*/
package org.apache.myfaces.custom.selectOneRow;
-import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import java.io.IOException;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.Map;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.shared_tomahawk.config.MyfacesConfig;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
/**
*
@@ -99,7 +101,7 @@ public class SelectOneRowRenderer extend
int currentRowIndex = getCurrentRowIndex(component);
return (value != null)
- && (currentRowIndex == ((Long) value).intValue());
+ && (currentRowIndex == ((Number) value).intValue());
}
@@ -144,11 +146,31 @@ public class SelectOneRowRenderer extend
String clientId = row.getClientId(context);
if (clientId.equals(postedValue))
{
-
String[] postedValueArray = postedValue.split(":");
String rowIndex = postedValueArray[postedValueArray.length - 2];
- Long newValue = Long.valueOf(rowIndex);
+ ValueBinding vb = row.getValueBinding("value");
+ Class type = vb.getType(context);
+ if (type == null)
+ {
+ type = (vb.getValue(context) != null) ? vb.getValue(context).getClass() : null;
+ }
+ Object newValue = null;
+ if (type != null)
+ {
+ if (type.isAssignableFrom(Long.class))
+ {
+ newValue = Long.valueOf(rowIndex);
+ }
+ else
+ {
+ newValue = Integer.valueOf(rowIndex);
+ }
+ }
+ else
+ {
+ newValue = Integer.valueOf(rowIndex);
+ }
//the value to go in conversion&validation
row.setSubmittedValue(newValue);
row.setValid(true);