You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2009/07/14 22:51:30 UTC

svn commit: r794062 - in /myfaces/trinidad/branches/1.2.11.4-branch: trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/FocusEvent.java trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java

Author: arobinson74
Date: Tue Jul 14 20:51:29 2009
New Revision: 794062

URL: http://svn.apache.org/viewvc?rev=794062&view=rev
Log:
TRINIDAD-1483
Applied patch

Modified:
    myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/FocusEvent.java
    myfaces/trinidad/branches/1.2.11.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java

Modified: myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/FocusEvent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/FocusEvent.java?rev=794062&r1=794061&r2=794062&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/FocusEvent.java (original)
+++ myfaces/trinidad/branches/1.2.11.4-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/event/FocusEvent.java Tue Jul 14 20:51:29 2009
@@ -25,21 +25,46 @@
 
 
 /**
- * Event delivered when focusing on a node in a tree. 
- * Currently this event doesn't deliver
- * much useful information as it doesn't
- * tell which node is getting focus.
- * This will provide more useful information in a later release.
+ * Event delivered when focusing on a node in a tree. The event includes information
+ * about the old and the new focus row keys.
  * <p>
  * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/event/FocusEvent.java#0 $) $Date: 10-nov-2005.19:09:01 $
  */
 public class FocusEvent extends FacesEvent
 {
-  public FocusEvent(UIComponent source)
+  /**
+   * Creates a new FocusEvent
+   * @param source source component
+   * @param oldKey old focus row key
+   * @param newKey new focus row key
+   */
+  public FocusEvent(UIComponent source, Object oldKey, Object  newKey)
   {
     super(source);
+    _oldKey  = oldKey;
+    _newKey  = newKey;    
+  }
+
+  /**
+   * The constructor with no key info is currently need for backwards compatibility.
+   * Will be remove at a later time.  
+   * @param source
+   */
+  public FocusEvent(UIComponent source)
+  {
+    this(source, null, null);
   }
   
+  public Object getOldKey()
+  {
+    return _oldKey;
+  }
+
+  public Object getNewKey()
+  {
+    return _newKey;
+  }
+
   @Override
   public void processListener(FacesListener listener)
   {
@@ -77,10 +102,16 @@
     sb.append(getClass().getName());
     sb.append("[component=");
     sb.append(getComponent());
+    sb.append(",oldKey=");
+    sb.append(getOldKey());
+    sb.append(",newKey=");
+    sb.append(getNewKey());
     sb.append(']');
     return sb.toString();
   }
 
+  private final Object _oldKey;
+  private final Object _newKey;
   private static final long serialVersionUID = 1L;
 }
 

Modified: myfaces/trinidad/branches/1.2.11.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.11.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java?rev=794062&r1=794061&r2=794062&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.11.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java (original)
+++ myfaces/trinidad/branches/1.2.11.4-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/table/TreeUtils.java Tue Jul 14 20:51:29 2009
@@ -262,10 +262,13 @@
             // this must be a root level range change:
             startParam = parameters.get(XhtmlConstants.VALUE_PARAM);
             newStart = Integer.parseInt(startParam) - 1; // value is based at one.
-            tree.setRowKey(tree.getFocusRowKey());
+            Object focusRowKey = tree.getFocusRowKey();
+            tree.setRowKey(focusRowKey);
             tree.setRowIndex(newStart);
-            // queue a focusChange event as well as range change event:
-            new FocusEvent(tree).queue();
+            // queue a focusChange event as well as range change event.
+            // TODO - The FocusRowKey has not changed only the start row index has changed.
+            // Is queueing a FocusEvent really necessary?
+            new FocusEvent(tree, focusRowKey,  focusRowKey).queue();
           }
           else // large record set navigation
           {
@@ -291,8 +294,13 @@
         @Override
         protected void process(UIXHierarchy tree)
         {
+          // if the current focusRowKey is null,  and the FocusRowKey attribute
+          // of the component is EL-bound,  this will call the EL getter, otherwise
+          // we get the "local" FocusRowKey set on the component
+          Object oldKey = tree.getFocusRowKey();
           _restorePathFromParam(parameters, tree);
-          new FocusEvent(tree).queue();
+          Object newKey = tree.getRowKey();
+          new FocusEvent(tree, oldKey, newKey).queue();
         }
       };
       preserve.run((UIXHierarchy) tree);