You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mc...@apache.org on 2008/03/12 17:29:24 UTC
svn commit: r636407 - in /myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main:
java-templates/org/apache/myfaces/trinidad/component/
java/org/apache/myfaces/trinidad/component/
Author: mcooper
Date: Wed Mar 12 09:29:19 2008
New Revision: 636407
URL: http://svn.apache.org/viewvc?rev=636407&view=rev
Log:
TRINIDAD-961 Non-functional partialTriggers for table column header/footer
Thanks to Kamran Kashanian for his patch.
Modified:
myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java
myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTableTemplate.java
myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java
myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java?rev=636407&r1=636406&r2=636407&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTableTemplate.java Wed Mar 12 09:29:19 2008
@@ -52,6 +52,24 @@
{
@Override
+ public String getContainerClientId(FacesContext context, UIComponent child)
+ {
+ String id;
+ if (_isStampedChild(child))
+ {
+ // call the UIXCollection getContainerClientId, which attaches currency string to the client id
+ id = getContainerClientId(context);
+ }
+ else
+ {
+ // The target is not a stamped child, so return a client id with no currency string
+ id = getClientId(context);
+ }
+
+ return id;
+ }
+
+ @Override
public void setSortCriteria(List<SortCriterion> criteria)
{
_sortCriteria = criteria;
@@ -401,6 +419,19 @@
setRowIndex(-1);
}
+ }
+
+ private boolean _isStampedChild(UIComponent target)
+ {
+ // Not stamped if target is in table header/footer:
+ if (TableUtils.__isInTableHeaderFooterFacet(this, target))
+ return false;
+
+ // Not stamped if target is in a column header/footer:
+ if (TableUtils.__isInColumnHeaderFooterFacet(this, target))
+ return false;
+
+ return true;
}
@Override
Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTableTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTableTemplate.java?rev=636407&r1=636406&r2=636407&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTableTemplate.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java-templates/org/apache/myfaces/trinidad/component/UIXTreeTableTemplate.java Wed Mar 12 09:29:19 2008
@@ -49,6 +49,24 @@
/**/ public abstract int[] getRowsByDepth();
/**/ abstract public MethodExpression getRangeChangeListener();
+ @Override
+ public String getContainerClientId(FacesContext context, UIComponent child)
+ {
+ String id;
+ if (_isStampedChild(child))
+ {
+ // call the UIXCollection getContainerClientId, which attaches currency string to the client id
+ id = getContainerClientId(context);
+ }
+ else
+ {
+ // The target is not a stamped child, so return a client id with no currency string
+ id = getClientId(context);
+ }
+
+ return id;
+ }
+
@Deprecated
public void setRangeChangeListener(MethodBinding binding)
{
@@ -330,6 +348,24 @@
Object parentKey = getTreeModel().getContainerRowKey();
return parentKey;
}
+
+ private boolean _isStampedChild(UIComponent target)
+ {
+ // Not stamped if target is in table header/footer:
+ if (TableUtils.__isInTableHeaderFooterFacet(this, target))
+ return false;
+
+ // Not stamped if target is in a column header/footer:
+ if (TableUtils.__isInColumnHeaderFooterFacet(this, target))
+ return false;
+
+ // Not stamped if target is in the nodeStamp column header/footer:
+ if (TableUtils.__isInNodeStampHeaderFooterFacet(this, target))
+ return false;
+
+ return true;
+ }
+
private Map<Object, Integer> _firstMap = Collections.emptyMap();
}
Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java?rev=636407&r1=636406&r2=636407&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/TableUtils.java Wed Mar 12 09:29:19 2008
@@ -18,6 +18,7 @@
*/
package org.apache.myfaces.trinidad.component;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -307,6 +308,126 @@
}
}
}
+
+ /**
+ * Determine if the target component is inside the table header/footer facet
+ * @param parent
+ * @param target
+ * @return
+ */
+ static boolean __isInTableHeaderFooterFacet(UIXCollection parent, UIComponent target)
+ {
+ return __isInHeaderFooterFacet(parent, target);
+ }
+
+ /**
+ * Determine if the target component is inside a column header/footer facet
+ * @param parent
+ * @param target
+ * @return
+ */
+ static boolean __isInColumnHeaderFooterFacet(UIXCollection parent, UIComponent target)
+ {
+ List<UIComponent> children = new ArrayList<UIComponent>();
+ children = _getColumns(parent, children);
+ for (UIComponent child : children)
+ {
+ if (__isInHeaderFooterFacet(child, target))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Determine if the target component is in the treeTable nodeStamp column
+ * header/footer
+ * @param tree
+ * @param target
+ * @return
+ */
+ static boolean __isInNodeStampHeaderFooterFacet(UIXTree tree, UIComponent target)
+ {
+ UIComponent nodeStamp = tree.getNodeStamp();
+ if (nodeStamp != null)
+ {
+ if (__isInHeaderFooterFacet(nodeStamp, target))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Determine if the target component is inside the parent header/footer facet
+ * @param parent
+ * @param target
+ * @return
+ */
+ static boolean __isInHeaderFooterFacet(UIComponent parent, UIComponent target)
+ {
+ UIComponent headerFacet = parent.getFacets().get("header");
+ if (headerFacet != null)
+ {
+ if (target == headerFacet || _isDescendant(headerFacet, target, null))
+ return true;
+ }
+
+ UIComponent footerFacet = parent.getFacets().get("footer");
+ if (footerFacet != null)
+ {
+ if (target == footerFacet || _isDescendant(footerFacet, target, null))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns all columns including column groups
+ * @param parent
+ * @param columns
+ * @return
+ */
+ static private List<UIComponent> _getColumns(UIComponent parent, List<UIComponent> columns)
+ {
+ List<UIComponent> children = parent.getChildren();
+ for (UIComponent child : children)
+ {
+ if (child instanceof UIXColumn)
+ {
+ columns.add(child);
+ columns = _getColumns(child, columns);
+ }
+ }
+ return columns;
+ }
+
+ /**
+ * Determine if target is a descendant of the parent parameter by recursively walking
+ * the parent's children. Optionally skip children of type skipType
+ * @param parent
+ * @param target
+ * @param skipType
+ * @return
+ */
+ static private <T> boolean _isDescendant(UIComponent parent, UIComponent target, Class<T> skipType)
+ {
+ List<UIComponent> children = parent.getChildren();
+ for (UIComponent child : children)
+ {
+ if ( (skipType == null || !skipType.isInstance(child)) && child == target)
+ {
+ return true;
+ }
+ else
+ {
+ if (_isDescendant(child, target, skipType))
+ return true;
+ }
+ }
+ return false;
+ }
/**
* Checks to see if the given event could possible be affected by the
Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java?rev=636407&r1=636406&r2=636407&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponent.java Wed Mar 12 09:29:19 2008
@@ -242,4 +242,13 @@
abstract public MethodExpression getAttributeChangeListener();
abstract public void markInitialState();
+
+ /**
+ * Provides additional context (the target child component for which the container
+ * client ID is requested) to a naming container for constructing a client ID.
+ * This is useful for components such as @link UIXTable and @link UIXTreeTable which need
+ * to return different container client IDs for stamped and non-stamped child components.
+ * @see UIXComponentBase#getClientId(FacesContext context)
+ */
+ abstract public String getContainerClientId(FacesContext context, UIComponent child);
}
Modified: myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java?rev=636407&r1=636406&r2=636407&view=diff
==============================================================================
--- myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java (original)
+++ myfaces/trinidad/trunk_1.2.x/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java Wed Mar 12 09:29:19 2008
@@ -173,6 +173,11 @@
return _facesBean;
}
+ @Override
+ public String getContainerClientId(FacesContext context, UIComponent child)
+ {
+ return getContainerClientId(context);
+ }
@Override
public void addAttributeChangeListener(AttributeChangeListener acl)
@@ -318,7 +323,14 @@
{
if (containerComponent instanceof NamingContainer)
{
- String contClientId = containerComponent.getContainerClientId(context);
+ String contClientId;
+
+ // Pass additional context information to naming containers which extend UIXComponent:
+ if (containerComponent instanceof UIXComponent)
+ contClientId = ((UIXComponent)containerComponent).getContainerClientId(context, this);
+ else
+ contClientId = containerComponent.getContainerClientId(context);
+
StringBuilder bld = __getSharedStringBuilder();
bld.append(contClientId).append(NamingContainer.SEPARATOR_CHAR).append(clientId);
clientId = bld.toString();