[richfaces-svn-commits] JBoss Rich Faces SVN: r18723 - in branches/cdk-8570: ui/iteration/ui/src/main/java/org/richfaces and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Aug 17 12:51:50 EDT 2010


Author: alexsmirnov
Date: 2010-08-17 12:51:49 -0400 (Tue, 17 Aug 2010)
New Revision: 18723

Added:
   branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java
Removed:
   branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstarctSubTableToggleControl.java
Modified:
   branches/cdk-8570/
   branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java
   branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
   branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/event/DataTablePreRenderListener.java
   branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
Log:
Merged revisions 18722 via svnmerge from 
https://svn.jboss.org/repos/richfaces/trunk

.......
  r18722 | abelevich | 2010-08-17 09:26:26 -0700 (Tue, 17 Aug 2010) | 1 line
  
  https://jira.jboss.org/browse/RF-8920, https://jira.jboss.org/browse/RF-9093
.......



Property changes on: branches/cdk-8570
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk:1-18715
   + /trunk:1-18722

Modified: branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java
===================================================================
--- branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java	2010-08-17 16:26:26 UTC (rev 18722)
+++ branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java	2010-08-17 16:51:49 UTC (rev 18723)
@@ -26,13 +26,17 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
-import java.util.Map.Entry;
 
+import javax.faces.FacesException;
 import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
 
+import org.ajax4jsf.renderkit.RendererUtils;
 import org.richfaces.component.AbstractDataScroller;
+import org.richfaces.component.UIDataAdaptor;
 
 public final class DataScrollerUtils {
 
@@ -87,7 +91,35 @@
         }
         return parent;
     }
+    
+    public static UIComponent findDataTable(AbstractDataScroller dataScroller) {
 
+        String forAttribute = dataScroller.getForComponent();
+        UIComponent forComp;
+        if (forAttribute == null) {
+            forComp = dataScroller;
+            while ((forComp = forComp.getParent()) != null) {
+                if (forComp instanceof UIData || forComp instanceof UIDataAdaptor) {
+                    return forComp;
+                }
+            }
+
+            throw new FacesException("could not find dataTable for  datascroller " + dataScroller.getId());
+
+        } else {
+            forComp = RendererUtils.getInstance().findComponentFor(dataScroller, forAttribute);
+        }
+
+        if (forComp == null) {
+            throw new IllegalArgumentException("could not find dataTable with id '" + forAttribute + "'");
+        } else if (!((forComp instanceof UIData) || (forComp instanceof UIDataAdaptor))) {
+            throw new IllegalArgumentException("component with id '" + forAttribute + "' must be of type "
+                + UIData.class.getName() + " or " + UIDataAdaptor.class + ", not type " + forComp.getClass().getName());
+        }
+
+        return forComp;
+    }
+
     public static List<AbstractDataScroller> findDataScrollers(UIComponent dataTable) {
         List<AbstractDataScroller> datascrollers = new ArrayList<AbstractDataScroller>();
         Map<String, UIComponent> facets = dataTable.getFacets();

Deleted: branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstarctSubTableToggleControl.java
===================================================================
--- branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstarctSubTableToggleControl.java	2010-08-17 16:26:26 UTC (rev 18722)
+++ branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstarctSubTableToggleControl.java	2010-08-17 16:51:49 UTC (rev 18723)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.component;
-
-import javax.faces.component.UIComponentBase;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-
-/**
- * @author Anton Belevich
- *
- */
-
- at JsfComponent(
-    type = AbstarctSubTableToggleControl.COMPONENT_TYPE,
-    family = AbstarctSubTableToggleControl.COMPONENT_FAMILY, 
-    generate = "org.richfaces.component.UISubTableToggleControl",
-    renderer = @JsfRenderer(type = "org.richfaces.SubTableRenderer"),
-    tag = @Tag( name = "subTableToggleControl")
- )
-public abstract class AbstarctSubTableToggleControl extends UIComponentBase {
-
-    public static final String COMPONENT_TYPE = "org.richfaces.SubTableToggleControl";
-
-    public static final String COMPONENT_FAMILY = "org.richfaces.SubTableToggleControl";
-    
-    public static final String DEFAULT_EVENT = "onclick"; 
-    
-    enum PropertyKeys {
-        forId
-    }
-
-    @Attribute
-    public abstract String getExpandLabel();
-    
-    @Attribute
-    public abstract String getCollapseLabel();
-
-    @Attribute
-    public abstract String getExpandIcon();
-
-    @Attribute
-    public abstract String getCollapseIcon();
-    
-    @Attribute(defaultValue = DEFAULT_EVENT)
-    public abstract String getEvent();
-
-    public String getFor() {
-        return (String)getStateHelper().eval(PropertyKeys.forId);
-    }
-    
-    public void setFor(String forId) {
-        getStateHelper().put(PropertyKeys.forId, forId);
-    }
-}

Modified: branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
===================================================================
--- branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java	2010-08-17 16:26:26 UTC (rev 18722)
+++ branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java	2010-08-17 16:51:49 UTC (rev 18723)
@@ -31,14 +31,12 @@
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIData;
 import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
 import javax.faces.event.AbortProcessingException;
 import javax.faces.event.FacesEvent;
 
 import org.ajax4jsf.component.IterationStateHolder;
-import org.ajax4jsf.renderkit.RendererUtils;
 import org.richfaces.DataScrollerUtils;
 import org.richfaces.cdk.annotations.Attribute;
 import org.richfaces.cdk.annotations.JsfComponent;
@@ -162,33 +160,7 @@
      */
 
     public UIComponent getDataTable() {
-        String forAttribute = (String) getAttributes().get(PropertyKeys.forComponent.toString());
-        UIComponent forComp;
-
-        if (forAttribute == null) {
-            forComp = this;
-
-            while ((forComp = forComp.getParent()) != null) {
-                if (forComp instanceof UIData || forComp instanceof UIDataAdaptor) {
-                    getStateHelper().put(PropertyKeys.forComponent, forComp.getId());
-                    return forComp;
-                }
-            }
-            throw new FacesException("could not find dataTable for  datascroller " + this.getId());
-
-        } else {
-            forComp = RendererUtils.getInstance().findComponentFor(this, forAttribute);
-        }
-
-        if (forComp == null) {
-            throw new IllegalArgumentException("could not find dataTable with id '" + forAttribute + "'");
-        } else if (!((forComp instanceof UIData) || (forComp instanceof UIDataAdaptor))) {
-
-            throw new IllegalArgumentException("component with id '" + forAttribute + "' must be of type "
-                + UIData.class.getName() + " or " + UIDataAdaptor.class + ", not type " + forComp.getClass().getName());
-        }
-
-        return forComp;
+        return DataScrollerUtils.findDataTable(this);
     }
 
     private int getFastStepOrDefault() {

Copied: branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java (from rev 18722, trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java)
===================================================================
--- branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java	                        (rev 0)
+++ branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractSubTableToggleControl.java	2010-08-17 16:51:49 UTC (rev 18723)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+
+ at JsfComponent(
+    type = AbstractSubTableToggleControl.COMPONENT_TYPE,
+    family = AbstractSubTableToggleControl.COMPONENT_FAMILY, 
+    generate = "org.richfaces.component.UISubTableToggleControl",
+    renderer = @JsfRenderer(type = "org.richfaces.SubTableToggleControlRenderer"),
+    tag = @Tag( name = "subTableToggleControl")
+ )
+public abstract class AbstractSubTableToggleControl extends UIComponentBase {
+
+    public static final String COMPONENT_TYPE = "org.richfaces.SubTableToggleControl";
+
+    public static final String COMPONENT_FAMILY = "org.richfaces.SubTableToggleControl";
+    
+    public static final String DEFAULT_EVENT = "onclick"; 
+    
+    enum PropertyKeys {
+        forId
+    }
+
+    @Attribute
+    public abstract String getExpandLabel();
+    
+    @Attribute
+    public abstract String getCollapseLabel();
+
+    @Attribute
+    public abstract String getExpandIcon();
+
+    @Attribute
+    public abstract String getCollapseIcon();
+    
+    @Attribute(defaultValue = DEFAULT_EVENT)
+    public abstract String getEvent();
+
+    public String getFor() {
+        return (String)getStateHelper().eval(PropertyKeys.forId);
+    }
+    
+    public void setFor(String forId) {
+        getStateHelper().put(PropertyKeys.forId, forId);
+    }
+}

Modified: branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/event/DataTablePreRenderListener.java
===================================================================
--- branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/event/DataTablePreRenderListener.java	2010-08-17 16:26:26 UTC (rev 18722)
+++ branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/event/DataTablePreRenderListener.java	2010-08-17 16:51:49 UTC (rev 18723)
@@ -49,7 +49,7 @@
     private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
 
     public boolean isListenerForSource(Object source) {
-        return ((source instanceof UIDataAdaptor) || (source instanceof UIData));
+        return ((source instanceof AbstractDataScroller) ||(source instanceof UIDataAdaptor) || (source instanceof UIData));
     }
 
     public AbstractDataScroller processActiveDatascroller(FacesContext facesContext, List<AbstractDataScroller> dataScrollers,
@@ -103,61 +103,70 @@
     }
 
     public void processEvent(SystemEvent event) throws AbortProcessingException {
-        UIComponent dataTable = (UIComponent) event.getSource();
-        List<AbstractDataScroller> dataScrollers = DataScrollerUtils.findDataScrollers(dataTable);
+        AbstractDataScroller activeDataScroller = null;
+        UIComponent dataTable = null;
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        UIComponent source = (UIComponent) event.getSource();
 
-        if (!dataScrollers.isEmpty()) {
+        if ((source instanceof UIDataAdaptor) || (source instanceof UIData)) {
+            dataTable = source;
+            List<AbstractDataScroller> dataScrollers = DataScrollerUtils.findDataScrollers(dataTable);
+            if(!dataScrollers.isEmpty()) { 
+                activeDataScroller = processActiveDatascroller(facesContext, dataScrollers, dataTable);
+            }    
 
-            FacesContext facesContext = FacesContext.getCurrentInstance();
+        } else if (source instanceof AbstractDataScroller) {
+            activeDataScroller = (AbstractDataScroller) source;
+            dataTable = activeDataScroller.getDataTable();
+        }
+        
+        String scrollerStateKey  = dataTable.getClientId(facesContext) + AbstractDataScroller.SCROLLER_STATE_ATTRIBUTE; 
+        boolean processed = dataTable.getAttributes().containsKey(scrollerStateKey);
+        if(!processed) {
+            if ((activeDataScroller != null) && (dataTable != null)) {
+                int rowCount = DataScrollerUtils.getRowCount(dataTable);
+                int rows = DataScrollerUtils.getRows(dataTable);
+                int pageCount = DataScrollerUtils.getPageCount(dataTable, rowCount, rows);
+                
+                int page = activeDataScroller.getPage();
+                int newPage = -1;
 
-            AbstractDataScroller activeComponent = processActiveDatascroller(facesContext, dataScrollers, dataTable);
+                if (page < 1) {
+                    newPage = 1;
+                } else if (page > pageCount) {
+                    newPage = (pageCount != 0 ? pageCount : 1);
+                }
 
-            int rowCount = DataScrollerUtils.getRowCount(dataTable);
-            int rows = DataScrollerUtils.getRows(dataTable);
+                if (newPage != -1) {
+                    Object label = MessageUtil.getLabel(facesContext, activeDataScroller);
+                    String formattedMessage = Messages.getMessage(Messages.DATASCROLLER_PAGE_MISSING, new Object[] { label,
+                        page, pageCount, newPage });
 
-            Integer pageCount = DataScrollerUtils.getPageCount(dataTable, rowCount, rows);
+                    LOG.warn(formattedMessage);
+                    page = newPage;
+                    dataTable.getAttributes().put(scrollerStateKey, page);
+                }
 
-            int page = activeComponent.getPage();
-            int newPage = -1;
+                int first;
+                String lastPageMode = activeDataScroller.getLastPageMode();
 
-            if (page < 1) {
-                newPage = 1;
-            } else if (page > pageCount) {
-                newPage = (pageCount != 0 ? pageCount : 1);
-            }
+                if (lastPageMode == null) {
+                    lastPageMode = AbstractDataScroller.PAGEMODE_SHORT;
+                } else if (!AbstractDataScroller.PAGEMODE_SHORT.equals(lastPageMode)
+                    && !AbstractDataScroller.PAGEMODE_FULL.equals(lastPageMode)) {
+                    throw new IllegalArgumentException("Illegal value of 'lastPageMode' attribute: '" + lastPageMode + "'");
+                }
 
-            if (newPage != -1) {
-                Object label = MessageUtil.getLabel(facesContext, activeComponent);
-                String formattedMessage = Messages.getMessage(Messages.DATASCROLLER_PAGE_MISSING, new Object[] { label,
-                    page, pageCount, newPage });
-
-                LOG.warn(formattedMessage);
-
-                page = newPage;
-                dataTable.getAttributes().put(
-                    dataTable.getClientId(facesContext) + AbstractDataScroller.SCROLLER_STATE_ATTRIBUTE, page);
-            }
-
-            int first;
-
-            String lastPageMode = activeComponent.getLastPageMode();
-
-            if (lastPageMode == null) {
-                lastPageMode = AbstractDataScroller.PAGEMODE_SHORT;
-            } else if (!AbstractDataScroller.PAGEMODE_SHORT.equals(lastPageMode)
-                && !AbstractDataScroller.PAGEMODE_FULL.equals(lastPageMode)) {
-                throw new IllegalArgumentException("Illegal value of 'lastPageMode' attribute: '" + lastPageMode + "'");
-            }
-
-            if (page != pageCount || AbstractDataScroller.PAGEMODE_SHORT.equals(lastPageMode)) {
-                first = (page - 1) * rows;
-            } else {
-                first = rowCount - rows;
-                if (first < 0) {
-                    first = 0;
+                if (page != pageCount || AbstractDataScroller.PAGEMODE_SHORT.equals(lastPageMode)) {
+                    first = (page - 1) * rows;
+                } else {
+                    first = rowCount - rows;
+                    if (first < 0) {
+                        first = 0;
+                    }
                 }
+                dataTable.getAttributes().put("first", first);
             }
-            dataTable.getAttributes().put("first", first);
         }
     }
 

Modified: branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
--- branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java	2010-08-17 16:26:26 UTC (rev 18722)
+++ branches/cdk-8570/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java	2010-08-17 16:51:49 UTC (rev 18723)
@@ -35,14 +35,16 @@
 import org.ajax4jsf.javascript.JSFunction;
 import org.ajax4jsf.renderkit.RendererBase;
 import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.cdk.annotations.JsfRenderer;
 import org.richfaces.component.AbstractSubTable;
-import org.richfaces.component.AbstarctSubTableToggleControl;
+import org.richfaces.component.AbstractSubTableToggleControl;
 
 /**
  * @author Anton Belevich
  */
 
 
+ at JsfRenderer(type = "org.richfaces.SubTableToggleControlRenderer", family = AbstractSubTableToggleControl.COMPONENT_FAMILY)
 @ResourceDependencies(
     {@ResourceDependency(library = "javax.faces", name = "jsf.js"),
     @ResourceDependency(name = "richfaces.js"), 
@@ -66,7 +68,7 @@
     }
 
     protected void encodeControl(FacesContext context, UIComponent component) throws IOException {
-        AbstarctSubTableToggleControl toggleControl = (AbstarctSubTableToggleControl) component;
+        AbstractSubTableToggleControl toggleControl = (AbstractSubTableToggleControl) component;
         AbstractSubTable subTable = findComponent(context, toggleControl);
 
         if (subTable != null) {
@@ -89,7 +91,7 @@
         }
     }
 
-    protected void encodeControl(FacesContext context, ResponseWriter writer, AbstarctSubTableToggleControl control,
+    protected void encodeControl(FacesContext context, ResponseWriter writer, AbstractSubTableToggleControl control,
                                  String switchType, boolean expanded, boolean visible) throws IOException {
         String state = getState(expanded);
         String styleClass = getStyleClass(context, control);
@@ -160,7 +162,7 @@
         writer.endElement(HTML.SPAN_ELEM);
     }
 
-    public HashMap<String, Object> encodeOptions(FacesContext context, AbstarctSubTableToggleControl toggleControl, AbstractSubTable subTable) {
+    public HashMap<String, Object> encodeOptions(FacesContext context, AbstractSubTableToggleControl toggleControl, AbstractSubTable subTable) {
         String forId = subTable.getClientId(context);
         String toggleControlId = toggleControl.getClientId(context);
 
@@ -175,15 +177,15 @@
         return options;
     }
 
-    public String getStyleClass(FacesContext context, AbstarctSubTableToggleControl control) {
+    public String getStyleClass(FacesContext context, AbstractSubTableToggleControl control) {
         return null;
     }
 
-    public String getStyle(FacesContext context, AbstarctSubTableToggleControl control) {
+    public String getStyle(FacesContext context, AbstractSubTableToggleControl control) {
         return null;
     }
 
-    protected AbstractSubTable findComponent(FacesContext context, AbstarctSubTableToggleControl toggleControl) {
+    protected AbstractSubTable findComponent(FacesContext context, AbstractSubTableToggleControl toggleControl) {
         String forId = toggleControl.getFor();
         if (forId != null && forId.length() > 0) {
 



More information about the richfaces-svn-commits mailing list