incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r418405 - in /incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main: java-templates/org/apache/myfaces/adf/component/ java/org/apache/myfaces/adf/component/
Date Fri, 30 Jun 2006 22:50:35 GMT
Author: awiner
Date: Fri Jun 30 15:50:35 2006
New Revision: 418405

URL: http://svn.apache.org/viewvc?rev=418405&view=rev
Log:
ADFFACES-18: In TableTree component, column's header facet doesn't run action invocation and
update values of it's children.

Modified:
    incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTableTemplate.java
    incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTreeTableTemplate.java
    incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/TableUtils.java

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTableTemplate.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTableTemplate.java?rev=418405&r1=418404&r2=418405&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTableTemplate.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTableTemplate.java
Fri Jun 30 15:50:35 2006
@@ -1,357 +1,357 @@
-/*
- * Copyright  2003-2006 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.myfaces.adf.component;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-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.adf.event.RowDisclosureEvent;
-import org.apache.myfaces.adf.event.RangeChangeEvent;
-import org.apache.myfaces.adf.event.SelectionEvent;
-import org.apache.myfaces.adf.event.SortEvent;
-import org.apache.myfaces.adf.model.CollectionModel;
-import org.apache.myfaces.adf.model.RowKeySet;
-import org.apache.myfaces.adf.model.RowKeySetImpl;
-
-/**
- * Base class for the Table component. The behaviour supported by this base class
- * include record navigation, sorting, selection and detail-disclosure.
- * <p>
- * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/main/java-templates/oracle/adf/view/faces/component/UIXTableTemplate.java#0
$) $Date: 10-nov-2005.19:07:51 $
- * @author The Oracle ADF Faces Team
- */
-abstract public class UIXTableTemplate extends UIXIteratorTemplate
-  implements CollectionComponent
-{
-
-  public void setSortCriteria(List criteria)
-  {
-    _sortCriteria = criteria;
-    super.setSortCriteria(criteria);
-  }
-
-  /**
-   * Sets the phaseID of UI events depending on the "immediate" property.
-   */
-  public void queueEvent(FacesEvent event)
-  {
-    TableUtils.__handleQueueEvent(this, event);
-    super.queueEvent(event);
-  }
-
-  /**
-   * Delivers an event to the appropriate listeners.
-   * @param event
-   * @throws javax.faces.event.AbortProcessingException
-   */
-  public void broadcast(FacesEvent event)
-    throws AbortProcessingException
-  {
-    // the order of processing is
-    // 1. do any default action handling
-    // 2. invoke any actionListener method binding
-    // 3. call all the registered ActionListener instances.
-
-    // Deliver to the default RangeChangeListener
-    if (event instanceof RangeChangeEvent)
-    {
-      RangeChangeEvent rEvent = (RangeChangeEvent) event;
-      int first = rEvent.getNewStart();
-      setFirst(first);
-      //pu: Implicitly record a Change for 'first' attribute
-      addAttributeChange("first", new Integer(first));
-      
-      if ((first == 0) && (rEvent.getNewEnd() == getRowCount()))
-      {
-        setShowAll(true);
-        //pu: Implicitly record a Change for 'showAll' attribute
-        addAttributeChange("showAll", Boolean.TRUE);
-      }
-      else if (isShowAll())
-      {
-        setShowAll(false);
-        //pu: Implicitly record a Change for 'showAll' attribute
-        addAttributeChange("showAll", Boolean.FALSE);
-      }
-
-      __broadcast(event, getRangeChangeListener());
-    }
-    else if (event instanceof RowDisclosureEvent)
-    {
-      RowDisclosureEvent eEvent = (RowDisclosureEvent) event;
-      RowKeySet set = getDisclosedRowKeys();
-      set.addAll(eEvent.getAddedSet());
-      set.removeAll(eEvent.getRemovedSet());
-      __broadcast(event, getRowDisclosureListener());
-    }
-    else if (event instanceof SortEvent)
-    {
-      SortEvent sEvent = (SortEvent) event;
-      setSortCriteria(sEvent.getSortCriteria());
-      __broadcast(event, getSortListener());
-    }
-    else if (event instanceof SelectionEvent)
-    {
-      //pu: Implicitly record a Change for 'selectionState' attribute
-      addAttributeChange("selectedRowKeys",
-                         getSelectedRowKeys());
-      __broadcast(event, getSelectionListener());
-    }
-
-    super.broadcast(event);
-  }
-
-
-/**/  abstract public void setDisclosedRowKeys(RowKeySet state);
-/**/  abstract public RowKeySet getDisclosedRowKeys();
-/**/  public abstract RowKeySet getSelectedRowKeys();
-/**/  public abstract void setSelectedRowKeys(RowKeySet model);
-/**/  abstract public void setFirst(int first);
-/**/  abstract public void setShowAll(boolean showAll);
-/**/  abstract public boolean isShowAll();
-/**/  abstract public UIComponent getDetailStamp();
-/**/  public abstract MethodBinding getRangeChangeListener();
-/**/  public abstract MethodBinding getSortListener();
-/**/  public abstract MethodBinding getRowDisclosureListener();
-/**/  public abstract MethodBinding getSelectionListener();
-/**/  public abstract boolean isImmediate();
-
-  public Object saveState(FacesContext context)
-  {
-    Object o = super.saveState(context);
-    if ((o == null) &&
-        ((_sortCriteria == null) || _sortCriteria.isEmpty()))
-      return null;
-
-    return new Object[]{o, _sortCriteria};
-  }
-
-  public void restoreState(FacesContext context, Object state)
-  {
-    Object[] array = (Object[]) state;
-    super.restoreState(context, array[0]);
-
-
-    // Get the sort criteria - but *don't* call setSortCriteria()
-    // here;  doing so would require getting the collection model,
-    // and that may invoke client code that isn't quite in a state
-    // to be invoked, in part because component "binding"s have not been
-    // evaluated yet.
-    List criteria = (List) array[1];
-    _sortCriteria = criteria;
-  }
-
-  
-  /**
-   * Gets the data for the first selected row.
-   * This is useful when using EL to get at column data for the selected
-   * row when using a tableSelectOne.
-   * @return null if there is nothing selected in the table.
-   */
-  public Object getSelectedRowData() 
-  {
-    RowKeySet state = getSelectedRowKeys();
-    Iterator keys = state.iterator();
-    if (keys.hasNext()) 
-    {
-      Object key = keys.next();
-      CollectionModel model = getCollectionModel();
-      Object old = model.getRowKey();
-      try
-      {
-        model.setRowKey(key);
-        return model.getRowData();
-      }
-      finally
-      {
-        model.setRowKey(old);
-      }
-    }
-    return null;
-  }
-
-  protected final void processFacetsAndChildren(
-    FacesContext context,
-    PhaseId phaseId)
-  {
-    // process all the facets of this table just once
-    // (except for the "detailStamp" facet which must be processed once
-    // per row):
-    TableUtils.__processFacets(context, this, this, phaseId,
-      UIXTable.DETAIL_STAMP_FACET);
-
-    // process all the facets of this table's column children:
-    TableUtils.__processColumnFacets(context, this, this, phaseId);
-
-    // process all the children and the detailStamp as many times as necessary
-    _processStamps(context, phaseId);
-  }
-
-  /**
-   * Gets the stamps. This returns the children of this component plus
-   * the detail stamp (if any).
-   * @todo cache the result.
-   */
-  protected final List getStamps()
-  {
-    List children = super.getStamps();
-    UIComponent detail = getDetailStamp();
-    if (detail != null)
-    {
-      List stamps = new ArrayList(children.size() + 1);
-      stamps.addAll(children);
-      stamps.add(detail);
-      return stamps;
-    }
-    return children;
-  }
-
-  /**
-   * Saves the state for the given stamp.
-   * This method avoids changing the state of facets on columns.
-   */
-  protected final Object saveStampState(FacesContext context, UIComponent stamp)
-  {
-    if (stamp instanceof UIXColumn)
-    {
-      // if it is a column, we don't want the facets processed.
-      // Only the children:
-      return StampState.saveChildStampState(context, stamp, this);
-    }
-    else
-      return super.saveStampState(context, stamp);
-  }
-
-  /**
-   * Restores the state for the given stamp.
-   * This method avoids changing the state of facets on columns.
-   */
-  protected final void restoreStampState(FacesContext context, UIComponent stamp,
-                                         Object stampState)
-  {
-    if (stamp instanceof UIXColumn)
-    {
-      // if it is a column, we don't want the facets processed.
-      // Only the children:
-      StampState.restoreChildStampState(context, stamp, this, stampState);
-    }
-    else
-      super.restoreStampState(context, stamp, stampState);
-  }
-
-  protected final CollectionModel createCollectionModel(
-    CollectionModel current,
-    Object value)
-  {
-    CollectionModel model = super.createCollectionModel(current, value); 
-
-    getSelectedRowKeys().setCollectionModel(model);
-    getDisclosedRowKeys().setCollectionModel(model);
-
-    // If we were perviously sorted, restore the sort order:
-    if (_sortCriteria != null)
-    {
-      model.setSortCriteria(_sortCriteria);
-    }
-
-    return model;
-  }
-
-  /**
-   * Gets the internal state of this component.
-   */
-  Object __getMyStampState()
-  {
-    Object[] state = new Object[6];
-    state[0] = _sortCriteria;
-    state[1] = super.__getMyStampState();
-    state[2] = new Integer(getFirst());
-    state[3] = Boolean.valueOf(isShowAll());
-    state[4] = getSelectedRowKeys();
-    state[5] = getDisclosedRowKeys();
-    return state;
-  }
-  
-  /**
-   * Sets the internal state of this component.
-   * @param stampState the internal state is obtained from this object.
-   */
-  void __setMyStampState(Object stampState)
-  {
-    Object[] state = (Object[]) stampState;
-    _sortCriteria = (List) state[0];
-    super.__setMyStampState(state[1]);
-    setFirst(((Integer) state[2]).intValue());
-    setShowAll(Boolean.TRUE == state[3]);
-    setSelectedRowKeys((RowKeySet) state[4]);
-    setDisclosedRowKeys((RowKeySet) state[5]);
-  }
-
-  private void _processStamps(
-    FacesContext context,
-    PhaseId phaseId)
-  {
-    // Process all the children
-    CollectionModel tableData = getCollectionModel();
-    if (tableData.getRowCount() != 0)
-    {
-      int startIndex = getFirst();
-      int endIndex = isShowAll() ? getRowCount()-1 : TableUtils.getLast(this);
-
-      UIComponent detail = getDetailStamp();
-      RowKeySet disclosureState =
-        (detail == null) ? null : getDisclosedRowKeys();
-
-      for (int i = startIndex; i <= endIndex; i++)
-      {
-        setRowIndex(i);
-        TableUtils.__processStampedChildren(context, this, phaseId);
-
-        if ((disclosureState != null) && disclosureState.isContained())
-        {
-          assert getRowIndex() == i;
-          processComponent(context, detail, phaseId);
-        }
-      }
-
-      setRowIndex(-1);
-    }
-  }
-
-
-  void __init()
-  {
-    super.__init();
-    if (getSelectedRowKeys() == null)
-      setSelectedRowKeys(new RowKeySetImpl());
-    if (getDisclosedRowKeys() == null)
-      setDisclosedRowKeys(new RowKeySetImpl());
-    // if "first" is valueBound, we can't deal with it changing 
-    // during the lifecycle. So stash it as a local value.
-    // see bug 4537121:
-    setFirst(getFirst());
-  }
-
-  transient private List _sortCriteria = null;
+/*
+ * Copyright  2003-2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.myfaces.adf.component;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+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.adf.event.RowDisclosureEvent;
+import org.apache.myfaces.adf.event.RangeChangeEvent;
+import org.apache.myfaces.adf.event.SelectionEvent;
+import org.apache.myfaces.adf.event.SortEvent;
+import org.apache.myfaces.adf.model.CollectionModel;
+import org.apache.myfaces.adf.model.RowKeySet;
+import org.apache.myfaces.adf.model.RowKeySetImpl;
+
+/**
+ * Base class for the Table component. The behaviour supported by this base class
+ * include record navigation, sorting, selection and detail-disclosure.
+ * <p>
+ * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-api/src/main/java-templates/oracle/adf/view/faces/component/UIXTableTemplate.java#0
$) $Date: 10-nov-2005.19:07:51 $
+ * @author The Oracle ADF Faces Team
+ */
+abstract public class UIXTableTemplate extends UIXIteratorTemplate
+  implements CollectionComponent
+{
+
+  public void setSortCriteria(List criteria)
+  {
+    _sortCriteria = criteria;
+    super.setSortCriteria(criteria);
+  }
+
+  /**
+   * Sets the phaseID of UI events depending on the "immediate" property.
+   */
+  public void queueEvent(FacesEvent event)
+  {
+    TableUtils.__handleQueueEvent(this, event);
+    super.queueEvent(event);
+  }
+
+  /**
+   * Delivers an event to the appropriate listeners.
+   * @param event
+   * @throws javax.faces.event.AbortProcessingException
+   */
+  public void broadcast(FacesEvent event)
+    throws AbortProcessingException
+  {
+    // the order of processing is
+    // 1. do any default action handling
+    // 2. invoke any actionListener method binding
+    // 3. call all the registered ActionListener instances.
+
+    // Deliver to the default RangeChangeListener
+    if (event instanceof RangeChangeEvent)
+    {
+      RangeChangeEvent rEvent = (RangeChangeEvent) event;
+      int first = rEvent.getNewStart();
+      setFirst(first);
+      //pu: Implicitly record a Change for 'first' attribute
+      addAttributeChange("first", new Integer(first));
+      
+      if ((first == 0) && (rEvent.getNewEnd() == getRowCount()))
+      {
+        setShowAll(true);
+        //pu: Implicitly record a Change for 'showAll' attribute
+        addAttributeChange("showAll", Boolean.TRUE);
+      }
+      else if (isShowAll())
+      {
+        setShowAll(false);
+        //pu: Implicitly record a Change for 'showAll' attribute
+        addAttributeChange("showAll", Boolean.FALSE);
+      }
+
+      __broadcast(event, getRangeChangeListener());
+    }
+    else if (event instanceof RowDisclosureEvent)
+    {
+      RowDisclosureEvent eEvent = (RowDisclosureEvent) event;
+      RowKeySet set = getDisclosedRowKeys();
+      set.addAll(eEvent.getAddedSet());
+      set.removeAll(eEvent.getRemovedSet());
+      __broadcast(event, getRowDisclosureListener());
+    }
+    else if (event instanceof SortEvent)
+    {
+      SortEvent sEvent = (SortEvent) event;
+      setSortCriteria(sEvent.getSortCriteria());
+      __broadcast(event, getSortListener());
+    }
+    else if (event instanceof SelectionEvent)
+    {
+      //pu: Implicitly record a Change for 'selectionState' attribute
+      addAttributeChange("selectedRowKeys",
+                         getSelectedRowKeys());
+      __broadcast(event, getSelectionListener());
+    }
+
+    super.broadcast(event);
+  }
+
+
+/**/  abstract public void setDisclosedRowKeys(RowKeySet state);
+/**/  abstract public RowKeySet getDisclosedRowKeys();
+/**/  public abstract RowKeySet getSelectedRowKeys();
+/**/  public abstract void setSelectedRowKeys(RowKeySet model);
+/**/  abstract public void setFirst(int first);
+/**/  abstract public void setShowAll(boolean showAll);
+/**/  abstract public boolean isShowAll();
+/**/  abstract public UIComponent getDetailStamp();
+/**/  public abstract MethodBinding getRangeChangeListener();
+/**/  public abstract MethodBinding getSortListener();
+/**/  public abstract MethodBinding getRowDisclosureListener();
+/**/  public abstract MethodBinding getSelectionListener();
+/**/  public abstract boolean isImmediate();
+
+  public Object saveState(FacesContext context)
+  {
+    Object o = super.saveState(context);
+    if ((o == null) &&
+        ((_sortCriteria == null) || _sortCriteria.isEmpty()))
+      return null;
+
+    return new Object[]{o, _sortCriteria};
+  }
+
+  public void restoreState(FacesContext context, Object state)
+  {
+    Object[] array = (Object[]) state;
+    super.restoreState(context, array[0]);
+
+
+    // Get the sort criteria - but *don't* call setSortCriteria()
+    // here;  doing so would require getting the collection model,
+    // and that may invoke client code that isn't quite in a state
+    // to be invoked, in part because component "binding"s have not been
+    // evaluated yet.
+    List criteria = (List) array[1];
+    _sortCriteria = criteria;
+  }
+
+  
+  /**
+   * Gets the data for the first selected row.
+   * This is useful when using EL to get at column data for the selected
+   * row when using a tableSelectOne.
+   * @return null if there is nothing selected in the table.
+   */
+  public Object getSelectedRowData() 
+  {
+    RowKeySet state = getSelectedRowKeys();
+    Iterator keys = state.iterator();
+    if (keys.hasNext()) 
+    {
+      Object key = keys.next();
+      CollectionModel model = getCollectionModel();
+      Object old = model.getRowKey();
+      try
+      {
+        model.setRowKey(key);
+        return model.getRowData();
+      }
+      finally
+      {
+        model.setRowKey(old);
+      }
+    }
+    return null;
+  }
+
+  protected final void processFacetsAndChildren(
+    FacesContext context,
+    PhaseId phaseId)
+  {
+    // process all the facets of this table just once
+    // (except for the "detailStamp" facet which must be processed once
+    // per row):
+    TableUtils.__processFacets(context, this, this, phaseId,
+      UIXTable.DETAIL_STAMP_FACET);
+
+    // process all the facets of this table's column children:
+    TableUtils.__processColumnFacets(context, this, this, phaseId);
+
+    // process all the children and the detailStamp as many times as necessary
+    _processStamps(context, phaseId);
+  }
+
+  /**
+   * Gets the stamps. This returns the children of this component plus
+   * the detail stamp (if any).
+   * @todo cache the result.
+   */
+  protected final List getStamps()
+  {
+    List children = super.getStamps();
+    UIComponent detail = getDetailStamp();
+    if (detail != null)
+    {
+      List stamps = new ArrayList(children.size() + 1);
+      stamps.addAll(children);
+      stamps.add(detail);
+      return stamps;
+    }
+    return children;
+  }
+
+  /**
+   * Saves the state for the given stamp.
+   * This method avoids changing the state of facets on columns.
+   */
+  protected final Object saveStampState(FacesContext context, UIComponent stamp)
+  {
+    if (stamp instanceof UIXColumn)
+    {
+      // if it is a column, we don't want the facets processed.
+      // Only the children:
+      return StampState.saveChildStampState(context, stamp, this);
+    }
+    else
+      return super.saveStampState(context, stamp);
+  }
+
+  /**
+   * Restores the state for the given stamp.
+   * This method avoids changing the state of facets on columns.
+   */
+  protected final void restoreStampState(FacesContext context, UIComponent stamp,
+                                         Object stampState)
+  {
+    if (stamp instanceof UIXColumn)
+    {
+      // if it is a column, we don't want the facets processed.
+      // Only the children:
+      StampState.restoreChildStampState(context, stamp, this, stampState);
+    }
+    else
+      super.restoreStampState(context, stamp, stampState);
+  }
+
+  protected final CollectionModel createCollectionModel(
+    CollectionModel current,
+    Object value)
+  {
+    CollectionModel model = super.createCollectionModel(current, value); 
+
+    getSelectedRowKeys().setCollectionModel(model);
+    getDisclosedRowKeys().setCollectionModel(model);
+
+    // If we were perviously sorted, restore the sort order:
+    if (_sortCriteria != null)
+    {
+      model.setSortCriteria(_sortCriteria);
+    }
+
+    return model;
+  }
+
+  /**
+   * Gets the internal state of this component.
+   */
+  Object __getMyStampState()
+  {
+    Object[] state = new Object[6];
+    state[0] = _sortCriteria;
+    state[1] = super.__getMyStampState();
+    state[2] = new Integer(getFirst());
+    state[3] = Boolean.valueOf(isShowAll());
+    state[4] = getSelectedRowKeys();
+    state[5] = getDisclosedRowKeys();
+    return state;
+  }
+  
+  /**
+   * Sets the internal state of this component.
+   * @param stampState the internal state is obtained from this object.
+   */
+  void __setMyStampState(Object stampState)
+  {
+    Object[] state = (Object[]) stampState;
+    _sortCriteria = (List) state[0];
+    super.__setMyStampState(state[1]);
+    setFirst(((Integer) state[2]).intValue());
+    setShowAll(Boolean.TRUE == state[3]);
+    setSelectedRowKeys((RowKeySet) state[4]);
+    setDisclosedRowKeys((RowKeySet) state[5]);
+  }
+
+  private void _processStamps(
+    FacesContext context,
+    PhaseId phaseId)
+  {
+    // Process all the children
+    CollectionModel tableData = getCollectionModel();
+    if (tableData.getRowCount() != 0)
+    {
+      int startIndex = getFirst();
+      int endIndex = isShowAll() ? getRowCount()-1 : TableUtils.getLast(this);
+
+      UIComponent detail = getDetailStamp();
+      RowKeySet disclosureState =
+        (detail == null) ? null : getDisclosedRowKeys();
+
+      for (int i = startIndex; i <= endIndex; i++)
+      {
+        setRowIndex(i);
+        TableUtils.__processStampedChildren(context, this, phaseId);
+
+        if ((disclosureState != null) && disclosureState.isContained())
+        {
+          assert getRowIndex() == i;
+          processComponent(context, detail, phaseId);
+        }
+      }
+
+      setRowIndex(-1);
+    }
+  }
+
+
+  void __init()
+  {
+    super.__init();
+    if (getSelectedRowKeys() == null)
+      setSelectedRowKeys(new RowKeySetImpl());
+    if (getDisclosedRowKeys() == null)
+      setDisclosedRowKeys(new RowKeySetImpl());
+    // if "first" is valueBound, we can't deal with it changing 
+    // during the lifecycle. So stash it as a local value.
+    // see bug 4537121:
+    setFirst(getFirst());
+  }
+
+  transient private List _sortCriteria = null;
 }

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTreeTableTemplate.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTreeTableTemplate.java?rev=418405&r1=418404&r2=418405&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTreeTableTemplate.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java-templates/org/apache/myfaces/adf/component/UIXTreeTableTemplate.java
Fri Jun 30 15:50:35 2006
@@ -257,6 +257,10 @@
     UIComponent nodeStamp = getNodeStamp();
     // process any facets of the nodeStamp column:
     TableUtils.__processFacets(context, this, nodeStamp, phaseId, null);
+
+    // process all the facets of this table's column children:
+    TableUtils.__processColumnFacets(context, this, this, phaseId);
+
     // recursively process any grandchild columns of the nodeStamp column:
     TableUtils.__processColumnFacets(context, this, nodeStamp, phaseId);
 

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/TableUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/TableUtils.java?rev=418405&r1=418404&r2=418405&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/TableUtils.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-api/src/main/java/org/apache/myfaces/adf/component/TableUtils.java
Fri Jun 30 15:50:35 2006
@@ -13,309 +13,309 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adf.component;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-
-import org.apache.myfaces.adf.event.DisclosureEvent;
-import org.apache.myfaces.adf.event.RowDisclosureEvent;
-import org.apache.myfaces.adf.event.FocusEvent;
-import org.apache.myfaces.adf.event.RangeChangeEvent;
-import org.apache.myfaces.adf.event.SelectionEvent;
-import org.apache.myfaces.adf.event.SortEvent;
-import org.apache.myfaces.adf.model.ModelUtils;
-import org.apache.myfaces.adf.model.RowKeySet;
-import org.apache.myfaces.adf.model.TreeModel;
-
-/**
- * utility methods for dealing with tables.
- * @author The Oracle ADF Faces Team
- */
-public final class TableUtils 
-{
-
-  /**
-   * Gets the index of the last visible row that should be
-   * displayed by the given table. This is usually 
-   * {@link CollectionComponent#getFirst} added to
-   * {@link CollectionComponent#getRows} minus 1, but it changes if 
-   * {@link CollectionComponent#getRowCount} returns
-   * insufficient rows.
-   * @return if this table is empty, this returns 
-   * {@link CollectionComponent#getFirst()} - 1
-   */
-  public static int getLast(CollectionComponent table)
-  {
-    return getLast(table, table.getFirst());
-  }
-
-  /**
-   * Gets the index of the last visible row that should be
-   * displayed by the given table. This is usually 
-   * rangeStart added to
-   * {@link CollectionComponent#getRows} minus 1, but it changes if 
-   * {@link CollectionComponent#getRowCount} returns
-   * insufficient rows.
-   * @return if this table is empty, this returns 
-   * rangeStart - 1
-   */
-  public static int getLast(CollectionComponent table, int rangeStart)
-  {
-    final int rangeEnd;
-    int blockSize = table.getRows();
-    // if the blockSize is zero, that means show everthing.
-    if (blockSize <= 0)
-    {
-      rangeEnd = Integer.MAX_VALUE;
-    }
-    else
-    {
-      rangeEnd = rangeStart + blockSize;
-    }
-    return ModelUtils.findLastIndex(table, rangeStart, rangeEnd) - 1;
-  }
-
-  /**
-   * Sets up an EL variable on the requestScope.
-   * @param name The name of the EL variable
-   * @param value The value of the EL variable
-   * @return any old value that was bound to the EL variable, or null
-   * if there was no old value.
-   */
-  public static Object setupELVariable(FacesContext context, String name, Object value)
-  {
-    Map requestMap = context.getExternalContext().getRequestMap();
-    if (value == null)
-      return requestMap.remove(name);
-    else
-      return requestMap.put(name, value);
-  }
-
-  /**
-   * Perform a safe expand all.
-   * Checks to make sure that a complete expand-all operation won't result in
-   * too many nodes being displayed to the user. If too many nodes will end
-   * up being displayed, this method only expands the immediate children before
-   * terminating. Otherwise, a complete expand-all operation is performed.
-   * @param maxSize the maximum number of nodes to display. A complete expand-all
-   * operation will not take place if more than this number of nodes 
-   * will end up being displayed.
-   * @param model this tree model must have its path pointing to a particular 
-   * node which must be a container.
-   */
-  static void __doSafeExpandAll(TreeModel model, RowKeySet state, int maxSize)
-  {
-    int size = _getSizeOfTree(model, maxSize);
-    if ((size < 0) || (size > maxSize))
-    {
-      // not safe to do expand all.
-      // first expand the current node:
-      state.add();
-      
-      // now only expand immediate children:
-      model.enterContainer();
-      int i=0;
-      while(true)
-      {
-        model.setRowIndex(i++);
-        if (!model.isRowAvailable())
-          break;
-        state.add();
-      }
-      model.exitContainer();
-    }
-    else // safe to do expand all:
-      state.addAll();
-  }
-
-  /**
-   * Computes the number of nodes in a subtree.
-   * @param model the path must point to a node.
-   * @param maxSize the maximum number of nodes that will be searched.
-   * this method returns once this limit is reached.
-   * @return -1 if the number of nodes is unknown.
-   * If the limit is hit, then returns the number of nodes that are known
-   * to exist at the time the limit was hit. This number may be larger than
-   * maxSize.
-   */
-  static int _getSizeOfTree(TreeModel model, int maxSize)
-  {
-    if (model.isRowAvailable() && model.isContainer())
-    {
-      model.enterContainer();
-      try
-      {
-        int size = model.getRowCount();
-        for(int i=0, sz=size; i<sz; i++)
-        {
-          if (size > maxSize)
-            return size;
-          model.setRowIndex(i);
-          int kidSize = _getSizeOfTree(model, maxSize - size);
-          if (kidSize < 0)
-            return -1;
-          size += kidSize;
-        }
-        return size;        
-      }
-      finally
-      {
-        model.exitContainer();
-      }
-    }
-    return 0;
-  }
-
-  /**
-   * This method sets the phaseID of the event
-   * according to the "immediate" property of this
-   * component.
-   * If "immediate" is set to true, this calls
-   * {@link FacesContext#renderResponse}
-   */
-  static void __handleQueueEvent(UIComponent comp, FacesEvent event)
-  {
-    if (_isImmediateEvent(comp, event))
-    {
-      String immediateAttr = UIXTree.IMMEDIATE_KEY.getName();
-      Object isImmediate = comp.getAttributes().get(immediateAttr);
-      if (Boolean.TRUE.equals(isImmediate))
-      {
-        event.setPhaseId(PhaseId.ANY_PHASE);
-        FacesContext context = FacesContext.getCurrentInstance();
-        context.renderResponse();
-      }
-      else
-      {
-        // the event should not execute before model updates are done. 
-        // otherwise, the updates will be done to the wrong rows.
-  
-        // we can't do this at the end of the UPDATE_MODEL phase because
-        // if there are errors during that phase, then we want to immediately render
-        // the response, and not deliver this ui event:
-        event.setPhaseId(PhaseId.INVOKE_APPLICATION);
-      }
-    }
-  }
-
-  /**
-   * Process all the facets of a component; these are
-   * generally not processed once per row.
-   * @param skipFacet the name of any facet that should not be processed 
-   * at this time.
-   */
-  static void __processFacets(
-    FacesContext context,
-    final UIXCollection table,
-    UIComponent  component,
-    final PhaseId phaseId,
-    String skipFacet)
-  {
-    Map facets = component.getFacets();
-    final UIComponent skip = (skipFacet != null)
-      ? (UIComponent) facets.get(skipFacet)
-      : null;
-                                           
-    new ChildLoop()
-    {
-      protected void process(FacesContext context, UIComponent facet)
-      {
-        if (facet != skip)
-          table.processComponent(context, facet, phaseId);
-      }
-    }.runAlways(context, facets.values());
-  }
-
-  /**
-   * Process all the facets of any children that are columns; these are
-   * generally not processed once per row.
-   */
-  static void __processColumnFacets(
-    FacesContext context,
-    final UIXCollection table,
-    UIComponent  column,
-    final PhaseId phaseId)
-  {
-    new ChildLoop()
-    {
-      protected void process(FacesContext context, UIComponent child)
-      {
-        if (child instanceof UIXColumn)
-        {
-          // process any facets of the child column:
-          __processFacets(context, table, child, phaseId, null);
-          // recursively process the facets of any grandchild columns:
-          __processColumnFacets(context, table, child, phaseId);
-        }
-      }
-    }.runAlways(context, column);
-  }
-
-  /**
-   * Process all the children of the given table
-   */
-  static void __processStampedChildren(
-    FacesContext context,
-    final UIXCollection table,
-    final PhaseId phaseId)
-  {
-    new ChildLoop()
-    {
-      protected void process(FacesContext context, UIComponent child)
-      {
-        table.processComponent(context, child, phaseId);
-      }
-    }.runAlways(context, table);
-  }
-  
-  /**
-   * Process all the children of the given table
-   */
-  static void __processChildren(
-    FacesContext context,
-    final UIXCollection comp,
-    final PhaseId phaseId)
-  {
-
-    // process the children
-    int childCount = comp.getChildCount();
-    if (childCount != 0)
-    {
-      List children = comp.getChildren();
-
-      for (int i = 0; i < childCount; i++)
-      {
-        UIComponent child = (UIComponent)children.get(i);
-        comp.processComponent(context, child, phaseId);
-      }
-    }          
-  }  
-
-  /**
-   * Checks to see if the given event could possible be affected by the 
-   * "immediate" property of the given component.
-   */
-  private static boolean _isImmediateEvent(UIComponent comp, FacesEvent event)
-  {
-    if (event.getComponent() == comp)
-    {
-      return 
-          (event instanceof RangeChangeEvent) ||
-          (event instanceof DisclosureEvent) ||
-          (event instanceof RowDisclosureEvent) ||
-          (event instanceof SelectionEvent) ||
-          (event instanceof SortEvent) ||
-          (event instanceof FocusEvent);
-    }
-    return false;
-  }
-
-  private TableUtils()
-  {
-  }
+package org.apache.myfaces.adf.component;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.adf.event.DisclosureEvent;
+import org.apache.myfaces.adf.event.RowDisclosureEvent;
+import org.apache.myfaces.adf.event.FocusEvent;
+import org.apache.myfaces.adf.event.RangeChangeEvent;
+import org.apache.myfaces.adf.event.SelectionEvent;
+import org.apache.myfaces.adf.event.SortEvent;
+import org.apache.myfaces.adf.model.ModelUtils;
+import org.apache.myfaces.adf.model.RowKeySet;
+import org.apache.myfaces.adf.model.TreeModel;
+
+/**
+ * utility methods for dealing with tables.
+ * @author The Oracle ADF Faces Team
+ */
+public final class TableUtils 
+{
+
+  /**
+   * Gets the index of the last visible row that should be
+   * displayed by the given table. This is usually 
+   * {@link CollectionComponent#getFirst} added to
+   * {@link CollectionComponent#getRows} minus 1, but it changes if 
+   * {@link CollectionComponent#getRowCount} returns
+   * insufficient rows.
+   * @return if this table is empty, this returns 
+   * {@link CollectionComponent#getFirst()} - 1
+   */
+  public static int getLast(CollectionComponent table)
+  {
+    return getLast(table, table.getFirst());
+  }
+
+  /**
+   * Gets the index of the last visible row that should be
+   * displayed by the given table. This is usually 
+   * rangeStart added to
+   * {@link CollectionComponent#getRows} minus 1, but it changes if 
+   * {@link CollectionComponent#getRowCount} returns
+   * insufficient rows.
+   * @return if this table is empty, this returns 
+   * rangeStart - 1
+   */
+  public static int getLast(CollectionComponent table, int rangeStart)
+  {
+    final int rangeEnd;
+    int blockSize = table.getRows();
+    // if the blockSize is zero, that means show everthing.
+    if (blockSize <= 0)
+    {
+      rangeEnd = Integer.MAX_VALUE;
+    }
+    else
+    {
+      rangeEnd = rangeStart + blockSize;
+    }
+    return ModelUtils.findLastIndex(table, rangeStart, rangeEnd) - 1;
+  }
+
+  /**
+   * Sets up an EL variable on the requestScope.
+   * @param name The name of the EL variable
+   * @param value The value of the EL variable
+   * @return any old value that was bound to the EL variable, or null
+   * if there was no old value.
+   */
+  public static Object setupELVariable(FacesContext context, String name, Object value)
+  {
+    Map requestMap = context.getExternalContext().getRequestMap();
+    if (value == null)
+      return requestMap.remove(name);
+    else
+      return requestMap.put(name, value);
+  }
+
+  /**
+   * Perform a safe expand all.
+   * Checks to make sure that a complete expand-all operation won't result in
+   * too many nodes being displayed to the user. If too many nodes will end
+   * up being displayed, this method only expands the immediate children before
+   * terminating. Otherwise, a complete expand-all operation is performed.
+   * @param maxSize the maximum number of nodes to display. A complete expand-all
+   * operation will not take place if more than this number of nodes 
+   * will end up being displayed.
+   * @param model this tree model must have its path pointing to a particular 
+   * node which must be a container.
+   */
+  static void __doSafeExpandAll(TreeModel model, RowKeySet state, int maxSize)
+  {
+    int size = _getSizeOfTree(model, maxSize);
+    if ((size < 0) || (size > maxSize))
+    {
+      // not safe to do expand all.
+      // first expand the current node:
+      state.add();
+      
+      // now only expand immediate children:
+      model.enterContainer();
+      int i=0;
+      while(true)
+      {
+        model.setRowIndex(i++);
+        if (!model.isRowAvailable())
+          break;
+        state.add();
+      }
+      model.exitContainer();
+    }
+    else // safe to do expand all:
+      state.addAll();
+  }
+
+  /**
+   * Computes the number of nodes in a subtree.
+   * @param model the path must point to a node.
+   * @param maxSize the maximum number of nodes that will be searched.
+   * this method returns once this limit is reached.
+   * @return -1 if the number of nodes is unknown.
+   * If the limit is hit, then returns the number of nodes that are known
+   * to exist at the time the limit was hit. This number may be larger than
+   * maxSize.
+   */
+  static int _getSizeOfTree(TreeModel model, int maxSize)
+  {
+    if (model.isRowAvailable() && model.isContainer())
+    {
+      model.enterContainer();
+      try
+      {
+        int size = model.getRowCount();
+        for(int i=0, sz=size; i<sz; i++)
+        {
+          if (size > maxSize)
+            return size;
+          model.setRowIndex(i);
+          int kidSize = _getSizeOfTree(model, maxSize - size);
+          if (kidSize < 0)
+            return -1;
+          size += kidSize;
+        }
+        return size;        
+      }
+      finally
+      {
+        model.exitContainer();
+      }
+    }
+    return 0;
+  }
+
+  /**
+   * This method sets the phaseID of the event
+   * according to the "immediate" property of this
+   * component.
+   * If "immediate" is set to true, this calls
+   * {@link FacesContext#renderResponse}
+   */
+  static void __handleQueueEvent(UIComponent comp, FacesEvent event)
+  {
+    if (_isImmediateEvent(comp, event))
+    {
+      String immediateAttr = UIXTree.IMMEDIATE_KEY.getName();
+      Object isImmediate = comp.getAttributes().get(immediateAttr);
+      if (Boolean.TRUE.equals(isImmediate))
+      {
+        event.setPhaseId(PhaseId.ANY_PHASE);
+        FacesContext context = FacesContext.getCurrentInstance();
+        context.renderResponse();
+      }
+      else
+      {
+        // the event should not execute before model updates are done. 
+        // otherwise, the updates will be done to the wrong rows.
+  
+        // we can't do this at the end of the UPDATE_MODEL phase because
+        // if there are errors during that phase, then we want to immediately render
+        // the response, and not deliver this ui event:
+        event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+      }
+    }
+  }
+
+  /**
+   * Process all the facets of a component; these are
+   * generally not processed once per row.
+   * @param skipFacet the name of any facet that should not be processed 
+   * at this time.
+   */
+  static void __processFacets(
+    FacesContext context,
+    final UIXCollection table,
+    UIComponent  component,
+    final PhaseId phaseId,
+    String skipFacet)
+  {
+    Map facets = component.getFacets();
+    final UIComponent skip = (skipFacet != null)
+      ? (UIComponent) facets.get(skipFacet)
+      : null;
+                                           
+    new ChildLoop()
+    {
+      protected void process(FacesContext context, UIComponent facet)
+      {
+        if (facet != skip)
+          table.processComponent(context, facet, phaseId);
+      }
+    }.runAlways(context, facets.values());
+  }
+
+  /**
+   * Process all the facets of any children that are columns; these are
+   * generally not processed once per row.
+   */
+  static void __processColumnFacets(
+    FacesContext context,
+    final UIXCollection table,
+    UIComponent  column,
+    final PhaseId phaseId)
+  {
+    new ChildLoop()
+    {
+      protected void process(FacesContext context, UIComponent child)
+      {
+        if (child instanceof UIXColumn)
+        {
+          // process any facets of the child column:
+          __processFacets(context, table, child, phaseId, null);
+          // recursively process the facets of any grandchild columns:
+          __processColumnFacets(context, table, child, phaseId);
+        }
+      }
+    }.runAlways(context, column);
+  }
+
+  /**
+   * Process all the children of the given table
+   */
+  static void __processStampedChildren(
+    FacesContext context,
+    final UIXCollection table,
+    final PhaseId phaseId)
+  {
+    new ChildLoop()
+    {
+      protected void process(FacesContext context, UIComponent child)
+      {
+        table.processComponent(context, child, phaseId);
+      }
+    }.runAlways(context, table);
+  }
+  
+  /**
+   * Process all the children of the given table
+   */
+  static void __processChildren(
+    FacesContext context,
+    final UIXCollection comp,
+    final PhaseId phaseId)
+  {
+
+    // process the children
+    int childCount = comp.getChildCount();
+    if (childCount != 0)
+    {
+      List children = comp.getChildren();
+
+      for (int i = 0; i < childCount; i++)
+      {
+        UIComponent child = (UIComponent)children.get(i);
+        comp.processComponent(context, child, phaseId);
+      }
+    }          
+  }  
+
+  /**
+   * Checks to see if the given event could possible be affected by the 
+   * "immediate" property of the given component.
+   */
+  private static boolean _isImmediateEvent(UIComponent comp, FacesEvent event)
+  {
+    if (event.getComponent() == comp)
+    {
+      return 
+          (event instanceof RangeChangeEvent) ||
+          (event instanceof DisclosureEvent) ||
+          (event instanceof RowDisclosureEvent) ||
+          (event instanceof SelectionEvent) ||
+          (event instanceof SortEvent) ||
+          (event instanceof FocusEvent);
+    }
+    return false;
+  }
+
+  private TableUtils()
+  {
+  }
 }



Mime
View raw message