[richfaces-svn-commits] JBoss Rich Faces SVN: r1375 - in trunk/richfaces/tree/src: main/java/org/richfaces/component/state and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Jun 28 13:11:59 EDT 2007


Author: nbelaevski
Date: 2007-06-28 13:11:59 -0400 (Thu, 28 Jun 2007)
New Revision: 1375

Modified:
   trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
   trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java
   trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java
   trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java
   trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java
Log:
- JUnit tests fixed
- http://jira.jboss.com/jira/browse/RF-216 fixed

Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -278,7 +278,11 @@
 					faces.getExternalContext().getRequestParameterMap().get(
 							getBaseClientId(faces) + LAST_ELEMENT_FLAG) != null);
 		} finally {
-			setRowKey(savedRowKey);
+			try {
+				setRowKey(faces, savedRowKey);
+			} catch (Exception e) {
+				faces.getExternalContext().log(e.getMessage(), e);
+			}
 		}
 	}
 
@@ -643,12 +647,18 @@
 	 */
 	public Object getRowData(Object rowKey) {
 		Object storedKey = getRowKey();
+		FacesContext context = FacesContext.getCurrentInstance();
+		
 		try {
-			setRowKey(rowKey);
+			setRowKey(context, rowKey);
 
 			return getRowData();
 		} finally {
-			setRowKey(storedKey);
+			try {
+				setRowKey(context, storedKey);
+			} catch (Exception e) {
+				context.getExternalContext().log(e.getMessage(), e);
+			}
 		}
 	}
 
@@ -659,13 +669,18 @@
 	 * @return {@link TreeNode} instance corresponding to the current row key
 	 */
 	public TreeNode getTreeNode(Object rowKey) {
+		FacesContext context = FacesContext.getCurrentInstance();
 		Object storedKey = getRowKey();
 		try {
-			setRowKey(rowKey);
+			setRowKey(context, rowKey);
 
 			return getTreeNode();
 		} finally {
-			setRowKey(storedKey);
+			try {
+				setRowKey(context, storedKey);
+			} catch (Exception e) {
+				context.getExternalContext().log(e.getMessage(), e);
+			}
 		}
 	}
 	

Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -53,7 +53,7 @@
 
 		public void process(FacesContext context, Object rowKey, Object argument)
 		throws IOException {
-			tree.setRowKey(rowKey);
+			tree.setRowKey(context, rowKey);
 			if (tree.isRowAvailable()) {
 				TreeRowKey nextKey = (TreeRowKey) rowKey;
 
@@ -223,7 +223,6 @@
 	}
 
 	public void expandAll(UITree tree) throws IOException {
-		FacesContext context = FacesContext.getCurrentInstance();
 		queuedCollapsedNodes.clear();
 		// SubTreeChildrenAppender infoAppender = null;
 		//
@@ -255,7 +254,6 @@
 	}
 
 	public void expandNode(UITree tree, final TreeRowKey rowKey) throws IOException {
-		FacesContext context = FacesContext.getCurrentInstance();
 		// SubTreeChildrenAppender infoAppender;
 		// if (storedPersister != null) {
 		// infoAppender = storedPersister.getAppender(rowKey);

Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -23,6 +23,8 @@
 
 import java.io.IOException;
 
+import javax.faces.context.FacesContext;
+
 import org.richfaces.component.LastElementAware;
 import org.richfaces.component.TreeRowKey;
 import org.richfaces.component.UITree;
@@ -51,7 +53,7 @@
 		this.floatingKey = floatingKey;
 	}
 	
-	public void followRowKey(TreeRowKey newRowKey) throws IOException {
+	public void followRowKey(FacesContext context, TreeRowKey newRowKey) throws IOException {
 		actualLast = lastElement;
 		resetLastElement();
 		
@@ -73,7 +75,7 @@
 
 			stackedLast = new Boolean(actualLast);
 			
-			this.tree.setRowKey(newRowKey);
+			this.tree.setRowKey(context, newRowKey);
 
 			if (delta > 0) {
 				afterUp(delta);
@@ -96,7 +98,7 @@
 				}
 			}
 
-			this.tree.setRowKey(null);
+			this.tree.setRowKey(context, null);
 
 			if (level != 0) {
 				afterUp(level);

Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -78,8 +78,8 @@
 			this.clientId = getClientId();
 		}
 
-		public void followRowKey(TreeRowKey newRowKey) throws IOException {
-			super.followRowKey(newRowKey);
+		public void followRowKey(FacesContext context, TreeRowKey newRowKey) throws IOException {
+			super.followRowKey(context, newRowKey);
 
 			this.expanded = this.tree.isExpanded();
 			this.clientId = getClientId();
@@ -170,7 +170,7 @@
 		public void process(FacesContext context, Object rowKey, Object argument)
 		throws IOException {
 
-			navigator.followRowKey((TreeRowKey) rowKey);
+			navigator.followRowKey(context, (TreeRowKey) rowKey);
 			
 			processAdvisors(context, (TreeRowKey)rowKey);
 
@@ -290,7 +290,7 @@
 
 				boolean encodeScripts = false;
 
-				tree.setRowKey(null);
+				tree.setRowKey(context, null);
 
 				//we should add xmlns to AJAX response
 				//we'll write neutral inner element and add xmlns there
@@ -306,7 +306,7 @@
 						Iterator ajaxKeysItr = ajaxKeys.iterator();
 						while (ajaxKeysItr.hasNext()) {
 							TreeRowKey key = (TreeRowKey) ajaxKeysItr.next();
-							tree.setRowKey(key);
+							tree.setRowKey(context, key);
 							
 							String id = tree.getNodeFacet().getClientId(context);
 							if (ids.isEmpty() || ids.contains(id) || ids.contains(tree.getClientId(context))/* handle tree updates requests */) {
@@ -322,8 +322,12 @@
 				} catch (Exception e) {
 					throw new FacesException(e);
 				} finally {
-					tree.setRowKey(null);
-					tree.restoreOrigValue();
+					try {
+						tree.setRowKey(context, null);
+						tree.restoreOrigValue();
+					} catch (Exception e) {
+						context.getExternalContext().log(e.getMessage(), e);
+					}
 				}
 				if (encodeScripts) {
 					writeScript(context, tree, encodedAreaIds, renderedAreas);
@@ -337,7 +341,11 @@
 				responseWriter.endElement("div");
 			}
 		} finally {
-			ComponentsVariableResolver.removeVariables(this, component);
+			try {
+				ComponentsVariableResolver.removeVariables(this, component);
+			} catch (Exception e) {
+				context.getExternalContext().log(e.getMessage(), e);
+			}
 		}
 	}
 
@@ -458,9 +466,9 @@
 			if (key != null) {
 				droppedDownToLevelFlag.setFlag();
 				openLevelDownTable(context, input, writer);
-				input.setRowKey((TreeRowKey) key);
+				input.setRowKey(context, key);
 			} else {
-				input.setRowKey(null);
+				input.setRowKey(context, null);
 			}
 
 			TreeDataModelEventNavigator levelNavigator = new RendererDataModelEventNavigator(input, rowKey, context,
@@ -478,7 +486,7 @@
 					
 					if (currentKey == null ? rowKey != null : !currentKey.equals(rowKey)) {
 						//currentKey NE rowKey
-						input.setRowKey(rowKey);
+						input.setRowKey(context, rowKey);
 					}
 					
 					UITreeNode nodeFacet = input.getNodeFacet();
@@ -499,7 +507,7 @@
 				closeLevelDownTable(context, input, writer);
 			}
 
-			levelNavigator.followRowKey(null);
+			levelNavigator.followRowKey(context, null);
 
 			ComponentVariables variables = ComponentsVariableResolver.getVariables(this, input);
 			String value = selectionValueHolder.getValue();
@@ -509,7 +517,7 @@
 				variables.setVariable("selectionId", "");
 			}
 		} finally {
-			input.setRowKey(null);
+			input.setRowKey(context, null);
 			input.restoreOrigValue();
 		}
 	}

Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseAllCommandEventTest.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -25,6 +25,9 @@
 import javax.faces.component.UIOutput;
 import javax.faces.event.FacesListener;
 
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UITree;
+
 import junit.framework.TestCase;
 
 /**
@@ -32,7 +35,7 @@
  * created 14.04.2007
  * 
  */
-public class CollapseAllCommandEventTest extends TestCase {
+public class CollapseAllCommandEventTest extends AbstractAjax4JsfTestCase {
 
 	private CollapseAllCommandEvent event;
 	/**
@@ -45,16 +48,16 @@
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#setUp()
 	 */
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		
-		this.event = new CollapseAllCommandEvent(new UIOutput());
+		this.event = new CollapseAllCommandEvent(application.createComponent(UITree.COMPONENT_TYPE));
 	}
 
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#tearDown()
 	 */
-	protected void tearDown() throws Exception {
+	public void tearDown() throws Exception {
 		super.tearDown();
 
 		this.event = null;

Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/CollapseNodeCommandEventTest.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -27,8 +27,10 @@
 import javax.faces.component.UIOutput;
 import javax.faces.event.FacesListener;
 
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
 import org.richfaces.component.ListRowKey;
 import org.richfaces.component.TreeRowKey;
+import org.richfaces.component.UITree;
 
 import junit.framework.TestCase;
 
@@ -37,7 +39,7 @@
  * created 14.04.2007
  * 
  */
-public class CollapseNodeCommandEventTest extends TestCase {
+public class CollapseNodeCommandEventTest extends AbstractAjax4JsfTestCase {
 
 	private CollapseNodeCommandEvent event;
 	private TreeRowKey treeRowKey;
@@ -52,7 +54,7 @@
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#setUp()
 	 */
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		
 		ArrayList keyBase = new ArrayList();
@@ -61,13 +63,13 @@
 		keyBase.add(new Long(-17));
 
 		this.treeRowKey = new ListRowKey(keyBase);
-		this.event = new CollapseNodeCommandEvent(new UIOutput(), treeRowKey);
+		this.event = new CollapseNodeCommandEvent(application.createComponent(UITree.COMPONENT_TYPE), treeRowKey);
 	}
 
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#tearDown()
 	 */
-	protected void tearDown() throws Exception {
+	public void tearDown() throws Exception {
 		super.tearDown();
 
 		this.event = null;

Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandAllCommandEventTest.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -25,6 +25,9 @@
 import javax.faces.component.UIOutput;
 import javax.faces.event.FacesListener;
 
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UITree;
+
 import junit.framework.TestCase;
 
 /**
@@ -32,7 +35,7 @@
  * created 14.04.2007
  * 
  */
-public class ExpandAllCommandEventTest extends TestCase {
+public class ExpandAllCommandEventTest extends AbstractAjax4JsfTestCase {
 
 	private ExpandAllCommandEvent event;
 	/**
@@ -45,16 +48,16 @@
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#setUp()
 	 */
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		
-		this.event = new ExpandAllCommandEvent(new UIOutput());
+		this.event = new ExpandAllCommandEvent(application.createComponent(UITree.COMPONENT_TYPE));
 	}
 
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#tearDown()
 	 */
-	protected void tearDown() throws Exception {
+	public void tearDown() throws Exception {
 		super.tearDown();
 
 		this.event = null;

Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java	2007-06-28 16:37:40 UTC (rev 1374)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/ExpandNodeCommandEventTest.java	2007-06-28 17:11:59 UTC (rev 1375)
@@ -27,8 +27,10 @@
 import javax.faces.component.UIOutput;
 import javax.faces.event.FacesListener;
 
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
 import org.richfaces.component.ListRowKey;
 import org.richfaces.component.TreeRowKey;
+import org.richfaces.component.UITree;
 
 import junit.framework.TestCase;
 
@@ -37,7 +39,7 @@
  * created 14.04.2007
  * 
  */
-public class ExpandNodeCommandEventTest extends TestCase {
+public class ExpandNodeCommandEventTest extends AbstractAjax4JsfTestCase {
 
 	private ExpandNodeCommandEvent event;
 	private TreeRowKey treeRowKey;
@@ -52,7 +54,7 @@
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#setUp()
 	 */
-	protected void setUp() throws Exception {
+	public void setUp() throws Exception {
 		super.setUp();
 		
 		ArrayList keyBase = new ArrayList();
@@ -61,13 +63,13 @@
 		keyBase.add(new Long(-17));
 
 		this.treeRowKey = new ListRowKey(keyBase);
-		this.event = new ExpandNodeCommandEvent(new UIOutput(), treeRowKey);
+		this.event = new ExpandNodeCommandEvent(application.createComponent(UITree.COMPONENT_TYPE), treeRowKey);
 	}
 
 	/* (non-Javadoc)
 	 * @see junit.framework.TestCase#tearDown()
 	 */
-	protected void tearDown() throws Exception {
+	public void tearDown() throws Exception {
 		super.tearDown();
 
 		this.event = null;




More information about the richfaces-svn-commits mailing list