[richfaces-svn-commits] JBoss Rich Faces SVN: r13347 - trunk/framework/api/src/main/java/org/richfaces/model.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Apr 1 12:27:48 EDT 2009


Author: nbelaevski
Date: 2009-04-01 12:27:48 -0400 (Wed, 01 Apr 2009)
New Revision: 13347

Added:
   trunk/framework/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java
Modified:
   trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
   trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
Log:
NPE in StackingTreeModel fixed

Added: trunk/framework/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java	                        (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java	2009-04-01 16:27:48 UTC (rev 13347)
@@ -0,0 +1,36 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * Marks complex tree row keys containing several segments
+ * 
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public interface ComplexTreeRowKey {
+
+	public int getKeySegmentsCount();
+	
+	public Object getKeySegment(int i);
+}

Modified: trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java	2009-04-01 16:20:07 UTC (rev 13346)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java	2009-04-01 16:27:48 UTC (rev 13347)
@@ -192,7 +192,21 @@
 		
 		while (hasNext) {
 		    T segment = iterator.next();
-			appendSegment(result, segment.toString());
+			
+		    if (segment instanceof ComplexTreeRowKey) {
+				ComplexTreeRowKey complexKey = (ComplexTreeRowKey) segment;
+				
+				int segmentsCount = complexKey.getKeySegmentsCount();
+				for (int i = 0; i < segmentsCount; i++) {
+				    appendSegment(result, complexKey.getKeySegment(i).toString());
+				    if (i < segmentsCount - 1) {
+				    	result.append(AbstractTreeDataModel.SEPARATOR);
+				    }
+				}
+				
+			} else {
+			    appendSegment(result, segment.toString());
+			}
 
 			hasNext = iterator.hasNext();
 

Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java	2009-04-01 16:20:07 UTC (rev 13346)
+++ trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java	2009-04-01 16:27:48 UTC (rev 13347)
@@ -28,7 +28,7 @@
  * 
  * @author Nick Belaevski
  */
-public class StackingTreeModelKey<T> implements Serializable {
+public class StackingTreeModelKey<T> implements Serializable, ComplexTreeRowKey {
 	/**
 	 * 
 	 */
@@ -84,4 +84,20 @@
 	public Object getModelKey() {
 		return modelKey;
 	}
+	
+	public int getKeySegmentsCount() {
+		return 2;
+	}
+	
+	public Object getKeySegment(int i) {
+		switch (i) {
+		case 0:
+			return modelId;
+		case 1:
+			return modelKey;
+			
+		default:
+			throw new IllegalArgumentException(String.valueOf(i));
+		}
+	}
 }
\ No newline at end of file




More information about the richfaces-svn-commits mailing list