Author: maksimkaszynski
Date: 2008-03-27 12:59:45 -0400 (Thu, 27 Mar 2008)
New Revision: 7315
Added:
trunk/ui/scrollableDataTable/src/main/config/converter/row-key.xml
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/convert/rowkey/
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/convert/rowkey/ScrollableDataTableRowKeyConverter.java
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
Log:
http://jira.jboss.com/jira/browse/RF-2669
Added: trunk/ui/scrollableDataTable/src/main/config/converter/row-key.xml
===================================================================
--- trunk/ui/scrollableDataTable/src/main/config/converter/row-key.xml
(rev 0)
+++ trunk/ui/scrollableDataTable/src/main/config/converter/row-key.xml 2008-03-27 16:59:45
UTC (rev 7315)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"http://labs.jboss.com/jbossrichfaces/component-config.dtd">
+
+<components>
+ <converter generate="false">
+ <id>org.richfaces.convert.rowkey.ScrollableDataTableRowKeyConverter</id>
+ <classname>org.richfaces.convert.rowkey.ScrollableDataTableRowKeyConverter</classname>
+ </converter>
+</components>
\ No newline at end of file
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2008-03-27
16:38:57 UTC (rev 7314)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2008-03-27
16:59:45 UTC (rev 7315)
@@ -12,6 +12,7 @@
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
@@ -433,7 +434,4 @@
}
-
-
-
}
Added:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/convert/rowkey/ScrollableDataTableRowKeyConverter.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/convert/rowkey/ScrollableDataTableRowKeyConverter.java
(rev 0)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/convert/rowkey/ScrollableDataTableRowKeyConverter.java 2008-03-27
16:59:45 UTC (rev 7315)
@@ -0,0 +1,45 @@
+/**
+ *
+ */
+package org.richfaces.convert.rowkey;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.model.ScrollableTableDataModel.SimpleRowKey;
+
+/**
+ * Converter for {@link SimpleRowKey}
+ * @author Maksim Kaszynski
+ *
+ */
+public class ScrollableDataTableRowKeyConverter implements Converter {
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String)
+ */
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+ try {
+ int i = Integer.parseInt(value);
+ return new SimpleRowKey(i);
+ } catch(Exception e) {
+ throw new ConverterException("Unable to convert value " + value + "to
" + SimpleRowKey.class, e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
+ */
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ if (value instanceof SimpleRowKey) {
+ SimpleRowKey key = (SimpleRowKey) value;
+ return key.toString();
+ }
+ throw new ConverterException("Value " + value + " is not supported by
this converter");
+ }
+
+}