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 2007/11/20 04:59:56 UTC

svn commit: r596534 - in /myfaces/trinidad/trunk/trinidad: trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Tree.xml

Author: arobinson74
Date: Mon Nov 19 19:59:56 2007
New Revision: 596534

URL: http://svn.apache.org/viewvc?rev=596534&view=rev
Log:
TRINIDAD-828 - New attribute of "initiallyExpanded" on tree and treeTable


Modified:
    myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java
    myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Tree.xml

Modified: myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java?rev=596534&r1=596533&r2=596534&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTemplate.java Mon Nov 19 19:59:56 2007
@@ -20,20 +20,20 @@
 
 import java.io.IOException;
 
-import java.util.Set;
-
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.el.MethodBinding;
 import javax.faces.event.AbortProcessingException;
 import javax.faces.event.FacesEvent;
 import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.trinidad.event.RowDisclosureEvent;
+import org.apache.myfaces.trinidad.event.SelectionEvent;
 import org.apache.myfaces.trinidad.model.CollectionModel;
 import org.apache.myfaces.trinidad.model.ModelUtils;
 import org.apache.myfaces.trinidad.model.RowKeySet;
 import org.apache.myfaces.trinidad.model.RowKeySetTreeImpl;
 import org.apache.myfaces.trinidad.model.TreeModel;
-import org.apache.myfaces.trinidad.event.SelectionEvent;
 
 /**
  * Base class for Tree component.
@@ -47,6 +47,7 @@
 /**/  public abstract void setSelectedRowKeys(RowKeySet keys);
 /**/  public abstract MethodBinding getRowDisclosureListener();
 /**/  public abstract UIComponent getNodeStamp();
+/**/  public abstract boolean isInitiallyExpanded();
   
   /**
    * Sets the phaseID of UI events depending on the "immediate" property.
@@ -118,5 +119,40 @@
       setDisclosedRowKeys(new RowKeySetTreeImpl());
     if (getSelectedRowKeys() == null)
       setSelectedRowKeys(new RowKeySetTreeImpl());
+  }
+  
+  private final static String EXPAND_ONCE_KEY = "initialExpandCompleted";
+
+  /**
+   * @see org.apache.myfaces.trinidad.component.UIXCollection#__encodeBegin(javax.faces.context.FacesContext)
+   */
+  @Override @SuppressWarnings("unchecked")
+  protected void __encodeBegin(FacesContext context) throws IOException
+  {
+    if (isInitiallyExpanded() && !Boolean.TRUE.equals(getAttributes().get(EXPAND_ONCE_KEY)))
+    {
+      Object rowKey = getFocusRowKey();
+      if (rowKey == null)
+      {
+        int oldIndex = getRowIndex();
+        setRowIndex(0);
+        rowKey = getRowKey();
+        setRowIndex(oldIndex);
+      }
+
+      setRowKey(rowKey);
+      RowKeySet old = getDisclosedRowKeys();
+      RowKeySet newset = old.clone();
+      newset.addAll();
+      
+      // use an event to ensure the row disclosure listener is called 
+      broadcast(new RowDisclosureEvent(old, newset, this));
+      
+      // use attributes to store that we have processed the initial expansion
+      // as there is no support for private properties in the plug-in at the
+      // moment
+      getAttributes().put(EXPAND_ONCE_KEY, Boolean.TRUE);
+    }
+    super.__encodeBegin(context);    
   }
 }

Modified: myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Tree.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Tree.xml?rev=596534&r1=596533&r2=596534&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Tree.xml (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/Tree.xml Mon Nov 19 19:59:56 2007
@@ -106,7 +106,21 @@
         <mfp:state-holder>yes</mfp:state-holder>
       </property-extension>
     </property>
-
+    <property>
+      <description>
+        <![CDATA[If upon initial rendering, the current subtree under the focused row path
+        should be expanded. A RowDisclosureEvent is broadcast from the encode begin of the 
+        component so that listeners are properly notified of the disclosure.]]>
+      </description>
+      <property-name>initiallyExpanded</property-name>
+      <property-class>boolean</property-class>
+      <default-value>false</default-value>
+      <property-extension>
+        <mfp:property-metadata>
+          <mfp:preferred>true</mfp:preferred>
+        </mfp:property-metadata>
+      </property-extension>
+    </property>
 
     <component-extension>
       <mfp:component-family>org.apache.myfaces.trinidad.Tree</mfp:component-family>